public ActionResult Update(UpdateUserViewModel viewModel) { if (Request.Files.Count > 0) { var file = Request.Files[0]; if (file != null && file.ContentLength > 0) { var fileName = Path.GetFileName(file.FileName); if (!Directory.Exists(Path.Combine(Server.MapPath("~/Content/signature/")))) { Directory.CreateDirectory(Path.Combine(Server.MapPath("~/Content/signature/"))); } var path = Path.Combine(Server.MapPath("~/Content/signature/"), fileName); var url = "/Content/signature/" + fileName; file.SaveAs(path); viewModel.SignatureImage = url; } } var request = viewModel.MapTo <UpdateUserRequest>(); var response = _userService.Update(request); TempData["IsSuccess"] = response.IsSuccess; TempData["Message"] = response.Message; if (response.IsSuccess) { return(RedirectToAction("Index")); } return(View("Update", viewModel)); }
public ActionResult Update(UpdateUserViewModel viewModel) { var request = viewModel.MapTo <UpdateUserRequest>(); var response = _userService.Update(request); TempData["IsSuccess"] = response.IsSuccess; TempData["Message"] = response.Message; if (response.IsSuccess) { return(RedirectToAction("Index")); } return(View("Update", viewModel)); }