public ActionResult Edit(CustomerEditVM customer2BUpdated) { if (ModelState.IsValid) { try { if (_mapper.verifyPW(_customerBL.GetCustomerByEmail(customer2BUpdated.CustomerEmail).CustomerPasswordHash, customer2BUpdated.CustomerPasswordHash)) { _customerBL.UpdateCustomer(_mapper.cast2Customer(customer2BUpdated)); Log.Information($"Customer updated-- Email: {customer2BUpdated.CustomerEmail}"); return(RedirectToAction(nameof(Index))); } else { Log.Information($"Customer not updated; incorrect password-- Email: {customer2BUpdated.CustomerEmail}"); return(RedirectToAction(nameof(Index))); } } catch (Exception e) { Helper.WriteError(e, "Error"); Helper.WriteFatal(e, "Fatal"); Helper.WriteVerbose(e, "Verbose"); return(View()); } } return(View()); }
public ActionResult Save(CustomerEditVM modelVM) { try { var curUser = accountUtil.GetCurrentUser(User); Customer model = CustomerService.GetByUserID(curUser.ID); if (model == null) { throw new Exception("Данные клиента не найдены"); } if (ModelState.IsValid) { model.FullName = modelVM.full_name; //model.FirstName = modelVM.FirstName; //model.LastName = modelVM.LastName; model.Bio = modelVM.bio; //model.SocialAreaID = modelVM.SocialAreaID; //model.SocialAreaHandle = modelVM.SocialAreaHandle; CustomerService.Update(model, curUser.ID); return(Ok()); } else { throw new Exception("Неверные данные"); } } catch (Exception ex) { return(CustomBadRequest(ex)); } }
// GET: CustomerController/Edit/5 public ActionResult Edit(int id) { Dozen2Models.Customer customer = _customerBL.GetCustomerByID(id); CustomerEditVM customerEditVM = _mapper.Map <CustomerEditVM>(customer); return(View(customerEditVM)); }
public ActionResult Edit(CustomerEditVM customerEditVM) { try { var customer = _mapper.Map <Dozen2Models.Customer>(customerEditVM); _customerBL.EditCustomer(customer); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }
public ActionResult customerEdit(CustomerEditVM customerEditVM, int?customer_id) { Customer customer = db.Customers.Find(customer_id); customer.customer_name = customerEditVM.customer_name; customer.customer_surname = customerEditVM.customer_surname; customer.customer_address = customerEditVM.customer_address; customer.customer_phone = customerEditVM.customer_phone; customer.schedule_id = customerEditVM.schedule_id; db.Entry(customer).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("customerDetail")); }
public IActionResult Index(CustomerEditVM modelVM) { var curUser = accountUtil.GetCurrentUser(User); Customer model = CustomerService.GetByID(modelVM.ID); if (model == null || !model.UserID.Equals(curUser.ID)) { return(NotFound()); } if (ModelState.IsValid) { try { model.FullName = modelVM.FullName; //model.FirstName = modelVM.FirstName; //model.LastName = modelVM.LastName; model.Bio = modelVM.Bio; //model.SocialAreaID = modelVM.SocialAreaID; //model.SocialAreaHandle = modelVM.SocialAreaHandle; CustomerService.Update(model, curUser.ID); ViewData["successfullySaved"] = true; } catch (Exception ex) { ModelState.AddModelError("", "Что-то пошло не так: " + ex.Message); } } else { ModelState.AddModelError("", "Неверные данные"); } if (model.AvatarID.HasValue) { model.Avatar = AttachmentService.GetByID(model.AvatarID.Value); } modelVM.Avatar = new AttachmentDetailsVM(model.Avatar); //ViewData["socialAreas"] = SocialAreaService.GetAsSelectList(/*modelVM.SocialAreaID ?? 0*/); ViewBag.firebaseUid = curUser.FirebaseUid; ViewBag.firebaseToken = FirebaseRegistrationTokenService.GetForWebByUserID(curUser.ID); return(View(modelVM)); }
public ActionResult Edit(CustomerEditVM customer2BUpdated) { if (ModelState.IsValid) { try { _logger.LogWarning($"Customer {customer2BUpdated.CustomerName} has been edited!"); _storeBL.UpdateCustomer(_mapper.cast2Customer(customer2BUpdated)); return(RedirectToAction(nameof(Index))); } catch { return(View()); } } return(View()); }
public ActionResult customerEdit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Customer customer = db.Customers.Find(id); CustomerEditVM customerEditVM = new CustomerEditVM(); customerEditVM.customer_id = customer.customer_id; customerEditVM.customer_name = customer.customer_name; customerEditVM.customer_surname = customer.customer_surname; customerEditVM.customer_phone = customer.customer_phone; customerEditVM.customer_address = customer.customer_address; customerEditVM.ScheduleList = GetScheduleList().ToList(); return(View(customerEditVM)); }
public IActionResult Index() { var curUser = accountUtil.GetCurrentUser(User); Customer model = CustomerService.GetActiveSingleDetailsWithRelatedDataByUserID(curUser.ID); if (model == null) { //return NotFound("Клиент не найден"); throw new Exception("Клиент по curUser.ID не найден"); } CustomerEditVM modelVM = new CustomerEditVM(model); ViewBag.firebaseUid = curUser.FirebaseUid; ViewBag.firebaseToken = FirebaseRegistrationTokenService.GetForWebByUserID(curUser.ID); return(View(modelVM)); }
public CustomerEditWindow(object selectedCust) { InitializeComponent(); DataContext = new CustomerEditVM(selectedCust); }