public async Task EditAsync(EditEducationalBackgroundViewModel viewModel) { var educationalBackground = await _educationalBackgrounds.FirstAsync(a => a.Id == viewModel.Id); _mappingEngine.Map(viewModel, educationalBackground); if (viewModel.AttachmentScan.HasValue()) educationalBackground.Attachment = Convert.FromBase64String(viewModel.AttachmentScan).ResizeImageFile(a4Width, a4height); else if (viewModel.AttachmentFile.HasFile()) { educationalBackground.Attachment = viewModel.AttachmentFile.InputStream.ResizeImageFile(a4Width, a4height); } educationalBackground.LasModifierId = _userManager.GetCurrentUserId(); }
public virtual async Task<ActionResult> Edit(EditEducationalBackgroundViewModel viewModel) { if (!await _educationalBackgroundService.IsInDb(viewModel.Id)) this.AddErrors("TitleId", "سابقه تحصیلی مورد نظر توسط یکی از کاربران در شبکه،حذف شده است"); if (!ModelState.IsValid) { return View(viewModel); } await _educationalBackgroundService.EditAsync(viewModel); await _unitOfWork.SaveAllChangesAsync(auditUserId:_userManager.GetCurrentUserId()); return RedirectToAction(MVC.EducationalBackground.List(viewModel.ApplicantId)); }
public async Task EditAsync(EditEducationalBackgroundViewModel viewModel) { var educationalBackground = await _educationalBackgrounds.FirstAsync(a => a.Id == viewModel.Id); _mappingEngine.Map(viewModel, educationalBackground); }
public async Task FillEditViewModel(EditEducationalBackgroundViewModel viewModel) { viewModel.StudyFields = await _titleService.GetAsSelectListItemAsync(TitleType.StudyField, viewModel.StudyFieldId); viewModel.Institutions = await _institutionService.GetAsSelectListItemAsync(viewModel.InstitutionId); }
public virtual async Task<ActionResult> Edit(EditEducationalBackgroundViewModel viewModel) { if (!_referentialTeacherService.CanManageTeacher(viewModel.TeacherId)) return HttpNotFound(); if (!await _educationalBackgroundService.IsInDb(viewModel.Id)) this.AddErrors("TitleId", "سابقه تحصیلی مورد نظر توسط یکی از کاربران در شبکه،حذف شده است"); if (!ModelState.IsValid) { await _educationalBackgroundService.FillEditViewModel(viewModel); return View( viewModel); } await _educationalBackgroundService.EditAsync(viewModel); var message = await _unitOfWork.ConcurrencySaveChangesAsync(); if (message.HasValue()) this.AddErrors("TitleId", string.Format(message, "سابقه تحصیلی استاد")); if (ModelState.IsValid) return RedirectToAction(MVC.EducationalBackground.List(viewModel.TeacherId)); await _educationalBackgroundService.FillEditViewModel(viewModel); return View( viewModel); }