public async Task <IActionResult> Add(NewEducationViewModel formData) { try { if (ModelState.IsValid) { //} //else //{ //var img = await Base64StringHandler.GetFormFileBase64StringAsync(formData.DocumentImg); //bool bIfExist = false; //var emp = from c in _db.EducationalDetails //where c.DocumentImage == img //select c; //try //{ //emp.ToList()[0].DocumentImage.ToString(); //bIfExist = true; //} // catch { } //if (bIfExist == true) //{ //ModelState.AddModelError("Documents", $"Education document already exists in the database."); //} //else //{ await _educationDetailServices.AddEducationDetailsAsync(new EducationalDetails { DateTimeAdded = DateTimeOffset.Now, DateTimeModified = DateTimeOffset.Now, Institution = formData.Institution, EmployeeId = formData.EmployeeId, Status = formData.Status, From = formData.Begin, To = formData.End, QualificationTitle = formData.QualificationTitle, QualificationId = formData.QualificationId, //DocumentImage = await Base64StringHandler.GetFormFileBase64StringAsync(formData.DocumentImg), UserAccount = User.Identity.Name }); TempData["Message"] = "Education details added successfully"; _logger.LogInformation($"Success: successfully added employee {formData.EmployeeId} education record by user={@User.Identity.Name.Substring(4)}"); return(RedirectToAction("add")); } } catch (ApplicationException error) { _logger.LogError( error, $"FAIL: failed to register {formData.EmployeeId} Education details. Internal Application Error.; user={@User.Identity.Name.Substring(4)}"); ModelState.AddModelError("Education", $"Failed to register record. {formData.EmployeeId} Contact IT ServiceDesk for support thank you."); } await LoadSelectListsAsync(); return(View(formData)); }
public ActionResult Create([FromRoute] int systemUserId, [FromBody] NewEducationViewModel model) { var education = new UserEducationModel() { DateAttendedEnd = model.DateAttendedEnd, DateAttendedStart = model.DateAttendedStart, Degree = model.Degree, IsCurrentEducation = model.IsCurrentEducation, ModeOfStudy = model.ModeOfStudy, School = model.School, SystemUserId = systemUserId }; _educationService.Create(education); return(Ok(MessageHelper.Success("The education have been created."))); }