public bool Update([FromBody] CandidateViewModel model) { var userName = RequestContext.Principal.Identity.Name; var result = _businessLayer.GetAllEmployeesAsync().Result; var user = result.Where(x => Convert.ToString(x.UserId) == model.AssignTo).FirstOrDefault(); var loggedInUser = result.Where(x => x.Email == userName).FirstOrDefault(); var statusId = _businessLayer.GetAllCandStatusAsync().Result.Where(x => Convert.ToString(x.CanStatusId) == model.CandidateStatus).First().CanStatusId; Data.AppTrackEntities.candidate candidate = new Data.AppTrackEntities.candidate { CurrentDesignation = model.CurrentDesignation, CurrentLocation = model.CurrentLocation, DOB = model.DateOfBirth, PrimaryEmail = model.Email, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, MobileNumber = model.MobileNumber, HomeTown = model.HomeTown, Source = model.Source, SecondaryEmail = model.SecondaryEmail, AlternateNumber = model.AlternateNumber, CanStatusId = statusId, ModifiedDate = DateTime.Now, CandidateId = model.CandidateId, //CreatedBy = user.UserId, AssignedTo = user.UserId, CurrentEmployer = model.CurrentEmployer, ExperienceMonths = model.ExperienceInMonths > 0 ? model.ExperienceInMonths : default(int?), ExperienceYears = model.ExperienceInYears > 0 ? model.ExperienceInYears : default(int?), IndustryId = model.Industry > 0 ? model.Industry : -1,//Possible of Exception ModifiedBy = user.UserId, Skills = model.SkillSet, SalaryInLacks = model.SalaryInLacs > 0 ? model.SalaryInLacs : default(int?), SalaryInThousands = model.SalaryInThousands > 0 ? model.SalaryInThousands : -1, NoticePeriod = model.NoticePeriod, }; try { _businessLayer.UpdateCandidate(candidate); return(true); } catch (Exception ex) { return(false); } }
public bool Create([FromBody] CandidateViewModel model) { // return true; var userName = RequestContext.Principal.Identity.Name; var user = _businessLayer.GetAllEmployeesAsync().Result.Where(x => x.Email == userName).FirstOrDefault(); var statusId = _businessLayer.GetAllCandStatusAsync().Result.Where(x => x.Name.ToUpper() == "CREATED").First().CanStatusId; Data.AppTrackEntities.candidate candidate = new Data.AppTrackEntities.candidate { CreateDate = DateTime.Now, CurrentDesignation = model.CurrentDesignation, CurrentLocation = model.CurrentLocation, DOB = model.DateOfBirth, PrimaryEmail = model.Email, FirstName = model.FirstName, LastName = model.LastName, MiddleName = model.MiddleName, MobileNumber = model.MobileNumber, HomeTown = model.HomeTown, Source = model.Source, SecondaryEmail = model.SecondaryEmail, AlternateNumber = model.AlternateNumber, CanStatusId = statusId, CreatedBy = user.UserId, AssignedTo = user.UserId, CurrentEmployer = model.CurrentEmployer, ExperienceMonths = model.ExperienceInMonths, ExperienceYears = model.ExperienceInYears, IndustryId = model.Industry, ModifiedBy = user.UserId, Skills = model.SkillSet, SalaryInLacks = model.SalaryInLacs, SalaryInThousands = model.SalaryInThousands, NoticePeriod = model.NoticePeriod, ModifiedDate = DateTime.Now }; try { _businessLayer.AddCandidate(candidate); return(true); } catch (Exception ex) { return(false); } }