public ActionResult Add(StaffActionView model) { try { HttpCookie reqCookies = Request.Cookies["StaffLoginCookie"]; ResponseStaffLogin login = JsonConvert.DeserializeObject <ResponseStaffLogin>(reqCookies.Value.ToString().UrlDecode()); if (ModelState.IsValid) { if (_staffBusiness.CheckExistsAccount(model.Account, 0)) { ModelState.AddModelError("ExistsAccountError", "Tài khoản này đã tồn tại trong hệ thống"); return(View(model)); } model.CreateBy = login.Account; if (_staffBusiness.Add(model)) { _staffBusiness.Save(); return(Redirect("/Staff/List")); } } return(View(model)); } catch (Exception) { return(View(model)); } }
private void Add_Click(object sender, RoutedEventArgs e) { if (staffViewModel.IsValidModel()) { var isSuccess = _staffBusiness.Add(staffViewModel); if (isSuccess) { MessageBox.Show("Đã thêm thành công!", "Add", MessageBoxButton.OK, MessageBoxImage.Information); } else { MessageBox.Show("Thêm không thành công!", "Add", MessageBoxButton.OK, MessageBoxImage.Error); InitializeData(); } } }