NotesWhat is notes.io?

Notes brand slogan

Notes - notes.io

public class EmployeeAssignmentResponseModel
{
public string? message { get; set; }
public Data? data { get; set; }
}

public class Data
{
public List<CANDIDATE>? CANDIDATE { get; set; }
}
public class CANDIDATE
{
public string? ID { get; set; }
public string? FIRSTNAME { get; set; }
public string? LASTNAME { get; set; }
public string? ADDRESS1 { get; set; }
public string? ADDRESS2 { get; set; }
public string? CITY { get; set; }
public string? ZIPCODE { get; set; }
public string? WORKPHONE { get; set; }
public string? WORKPHONE_EXT { get; set; }
public string? HOMEPHONE { get; set; }
public string? CELLPHONE { get; set; }
public string? FAX { get; set; }
public string? EMAIL { get; set; }
public string? ALTERNATEEMAIL { get; set; }
public string? COUNTRY { get; set; }
public List<QUALIFICATION>? QUALIFICATIONS { get; set; }
public HR? HR { get; set; }
}

public class HR
{
public string? LEGAL_FIRST_NAME { get; set; }
public string? LEGAL_MIDDLE_NAME { get; set; }
public string? LEGAL_LAST_NAME { get; set; }
public string? VISA_STATUS { get; set; }
public string? MARTIAL_STATUS { get; set; }
public string? DATE_OF_BIRTH { get; set; }
public string? SSN { get; set; }
public string? SUFFIX { get; set; }
} this is API response model

public class Candidate
{
[Key]
public int TableId { get; set; }
public string? id { get; set; }
public string? firstname { get; set; }
public string? lastname { get; set; }
public string? Email { get; set; }
public string? cellphone { get; set; }
public string? currentsalaryper { get; set; }
public string? typeofConsultant { get; set; }
public string? country { get; set; }
public DateTime? ModifiedDate { get; set; }
}

public class HRTable
{
[Key]
public int Id { get; set; }
public string? EmployeeId { get; set; }
public string? FirstName { get; set; }
public string? MiddleName { get; set; }
public string? LastName { get; set; }
public string? VisaStatus { get; set; }
public string? MartialStatus { get; set; }
public DateTime? DOB { get; set; }
public string? SSN { get; set; }
public DateTime? CreatedDate { get; set; }
public DateTime? ModifiedDate { get; set; }
} this is my Entity Model

public async Task StoreEmpDataToDB(EmployeeAssignmentResponseModel obj)
{
using (var transaction = dbContext.Database.BeginTransaction())
{
try
{
Int64 employeeId = 0;
// Store and Update Candidate Data
var candidateDataToStore = mapper.Map<List<Candidate>>(obj.data?.CANDIDATE);
if (candidateDataToStore.Count > 0)
{
employeeId = Convert.ToInt64(candidateDataToStore[0].id);
}
foreach (var candidate in candidateDataToStore)
{
var existingCandidate = await dbContext.Candidate.Where(c => c.id == candidate.id && c.Email == candidate.Email).FirstOrDefaultAsync();
if (existingCandidate == null)
{
await dbContext.Candidate.AddAsync(candidate);
}
else
{
candidate.TableId = existingCandidate.TableId;
candidate.ModifiedDate = DateTime.Now;
dbContext.Entry(existingCandidate).CurrentValues.SetValues(candidate);
dbContext.Entry(existingCandidate).State = EntityState.Detached;
dbContext.Candidate.Attach(candidate);
dbContext.Entry(candidate).Property(x => x.ModifiedDate).IsModified = true;

dbContext.Entry(candidate).Property(x => x.id).IsModified = true;
dbContext.Entry(candidate).Property(x => x.firstname).IsModified = true;
dbContext.Entry(candidate).Property(x => x.lastname).IsModified = true;
dbContext.Entry(candidate).Property(x => x.Email).IsModified = true;
dbContext.Entry(candidate).Property(x => x.cellphone).IsModified = true;
dbContext.Entry(candidate).Property(x => x.currentsalaryper).IsModified = true;
dbContext.Entry(candidate).Property(x => x.typeofConsultant).IsModified = true;
dbContext.Entry(candidate).Property(x => x.country).IsModified = true;
}
}
await dbContext.SaveChangesAsync();
transaction.Commit();
}
catch (Exception ex)
{
transaction.Rollback();
logExceptionService.WriteToFile("Exception Error in StoreEmpDataToDB Method", ex.Message);
throw new Exception(AppConstants.ErrorSavingDataToTheDatabase + ex.Message);
}
}
}
I want to store HR data in HRTable please write complete code
     
 
what is notes.io
 

Notes.io is a web-based application for taking notes. You can take your notes and share with others people. If you like taking long notes, notes.io is designed for you. To date, over 8,000,000,000 notes created and continuing...

With notes.io;

  • * You can take a note from anywhere and any device with internet connection.
  • * You can share the notes in social platforms (YouTube, Facebook, Twitter, instagram etc.).
  • * You can quickly share your contents without website, blog and e-mail.
  • * You don't need to create any Account to share a note. As you wish you can use quick, easy and best shortened notes with sms, websites, e-mail, or messaging services (WhatsApp, iMessage, Telegram, Signal).
  • * Notes.io has fabulous infrastructure design for a short link and allows you to share the note as an easy and understandable link.

Fast: Notes.io is built for speed and performance. You can take a notes quickly and browse your archive.

Easy: Notes.io doesn’t require installation. Just write and share note!

Short: Notes.io’s url just 8 character. You’ll get shorten link of your note when you want to share. (Ex: notes.io/q )

Free: Notes.io works for 12 years and has been free since the day it was started.


You immediately create your first note and start sharing with the ones you wish. If you want to contact us, you can use the following communication channels;


Email: [email protected]

Twitter: http://twitter.com/notesio

Instagram: http://instagram.com/notes.io

Facebook: http://facebook.com/notesio



Regards;
Notes.io Team

     
 
Shortened Note Link
 
 
Looding Image
 
     
 
Long File
 
 

For written notes was greater than 18KB Unable to shorten.

To be smaller than 18KB, please organize your notes, or sign in.