public async Task <IActionResult> Update_Schedule_POST(SchedulesViewModel model) { try { //converting enum values to int model.status = Convert.ToInt32(model.statusvalue); await _schedulesPage.UpdateSchedule(model); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(RedirectToAction("ScheduleDetails", new { scheduleId = model.ID })); }
public async Task <IActionResult> UpdateScheduleOfJobApplicationPost(SchedulesViewModel model) { List <SchedulesUsers> collection = new List <SchedulesUsers>(); List <string> interviewers = new List <string>(); JobApplications jobApplication = new JobApplications(); try { //converting enum values to int model.status = Convert.ToInt32(model.statusvalue); //saving all the interviewers interviewers = model.Multiinterviewer; //all data of ScheduleUser composite table collection = _dbContext.SchedulesUsers.Where(x => x.scheduleId == model.ID).ToList(); //removing the existing pairs of old schedules interviewers _dbContext.SchedulesUsers.RemoveRange(collection); _dbContext.SaveChanges(); //adding new records of composite key into schedule users for new userschedule pairs foreach (var item in interviewers) { SchedulesUsersViewModel newModel = new SchedulesUsersViewModel() { scheduleId = model.ID, UserId = item }; await _schedulesUsersPage.AddNewSchedulesUsers(newModel); } await _schedulesPage.UpdateSchedule(model); //redirecting to details of job Application jobApplication = _dbContext.jobApplications.Where(x => x.candidateId == model.candidateId).FirstOrDefault(); }catch (Exception ex) { Console.WriteLine(ex.Message); } return(RedirectToAction("Details", "JobApplication", new { id = jobApplication.ID })); }