public virtual ActionResult Save(CustomerLogoModel customerModel) { if (!ModelState.IsValid) { return(View("Create", customerModel)); } if (customerModel.CustomerLogoId <= 0) //Create News { var customer = new CustomerLogo() { CustomerName = customerModel.CustomerName, LogoUrl = customerModel.LogoUrl, HomePageUrl = customerModel.HomePageUrl }; using (UnitOfWork) { Repository.Insert(customer); } } else //Edit user { var customer = Repository.GetById(customerModel.CustomerLogoId); customer.CustomerName = customerModel.CustomerName; customer.LogoUrl = customerModel.LogoUrl; customer.HomePageUrl = customerModel.HomePageUrl; using (UnitOfWork) { Repository.Update(customer); } } //Save success SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Logo khách hàng")); return(RedirectToAction("Index", new { area = "Administrator" })); }
public virtual ActionResult Edit(int id) { var entity = Repository.GetById(id); var model = new CustomerLogoModel() { CustomerLogoId = entity.CustomerLogoId, CustomerName = entity.CustomerName, LogoUrl = entity.LogoUrl, HomePageUrl = entity.HomePageUrl }; return(View("Edit", model)); }
public ActionResult Create() { var model = new CustomerLogoModel(); return(View(model)); }