public async Task <SaveCV_FormResponse> UpdateAsync(int id, CV_Form cv) { var existingCV = await _cvRepository.FindByIdAsync(id); if (_cvRepository == null) { return(new SaveCV_FormResponse("CV_Form not found.")); } //existingCV.announcement_id = cv.announcement_id; existingCV.date = cv.date; existingCV.name = cv.name; existingCV.date = cv.date; existingCV.email = cv.email; existingCV.date = cv.date; existingCV.dob = cv.dob; existingCV.nrc = cv.nrc; existingCV.ph_no_work = cv.ph_no_work; existingCV.ph_no_personal = cv.ph_no_personal; existingCV.gender = cv.gender; existingCV.marital_status = cv.marital_status; existingCV.nationality = cv.nationality; existingCV.religion = cv.religion; existingCV.permanent_address = cv.permanent_address; existingCV.qualification = cv.qualification; existingCV.address_id = cv.address_id; existingCV.joined_date = cv.joined_date; existingCV.status = cv.status; existingCV.Addresses.line_1 = cv.Addresses.line_1; existingCV.Addresses.line_2 = cv.Addresses.line_2; existingCV.Addresses.Township.Name = cv.Addresses.Township.Name; existingCV.Addresses.Township.city.Name = cv.Addresses.Township.city.Name; existingCV.Addresses.region = cv.Addresses.region; existingCV.Addresses.country = cv.Addresses.country; existingCV.Announcement.description = cv.Announcement.description; existingCV.Announcement.title = cv.Announcement.title; existingCV.Announcement.date = cv.Announcement.date; try { _cvRepository.Update(existingCV); await _unitOfWork.CompleteAsync(); return(new SaveCV_FormResponse(existingCV)); } catch (Exception ex) { // Do some logging stuff return(new SaveCV_FormResponse($"An error occurred when saving the attendence: {ex.Message}")); } }
public async Task <SaveCV_FormResponse> SaveAsync(CV_Form cv) { try { await _cvRepository.AddAsync(cv); await _unitOfWork.CompleteAsync(); return(new SaveCV_FormResponse(cv)); } catch (Exception ex) { // Do some logging stuff return(new SaveCV_FormResponse($"An error occurred when saving the CV_form: {ex.Message}")); } }
public async Task <IActionResult> PostAsync([FromBody] CV_Form attendence) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); //test valid or not } var result = await _cvService.SaveAsync(attendence); if (!result.Success) { return(BadRequest(result.Message)); } return(Ok()); }
public async Task <IActionResult> PutAsync(int id, [FromBody] CV_Form resource) { if (!ModelState.IsValid) { return(BadRequest(ModelState.GetErrorMessages())); } //map data from SaveResource & save back //var attendence=_mapper.Map<SaveCV_FormResource,CV_Form>(resource); var result = await _cvService.UpdateAsync(id, resource); if (result == null) { return(BadRequest(result)); } var attendenceResource = _mapper.Map <CV_Form, CV_FormResource>(result.CV_Form); return(Ok()); }
public void Update(CV_Form cv) { _context.CV_Forms.Update(cv); }
public void Remove(CV_Form cv) { _context.CV_Forms.Remove(cv); }
public async Task AddAsync(CV_Form cv) { await _context.CV_Forms.AddAsync(cv); }
/// <summary> /// Creates a success response. /// </summary> /// <param name="role">Saved Attendence.</param> /// <returns>Response.</returns> public SaveCV_FormResponse(CV_Form cv_form) : this(true, string.Empty, cv_form) { }
private SaveCV_FormResponse(bool success, string message, CV_Form cv_form) : base(success, message) { CV_Form = cv_form; }