public virtual ActionResult Edit(int id) { var entity = Repository.GetById(id); var model = new ExtraFeeModel() { ExtraFeeId = entity.ExtraFeeId, AmountFrom = entity.AmountFrom, AmountTo = entity.AmountTo, Cost = entity.Cost, ExtraFeeName = entity.ExtraFeeName }; return(View("Edit", model)); }
public virtual ActionResult Save(ExtraFeeModel myOfficeModel) { if (myOfficeModel.ExtraFeeId <= 0) //Create News { if (!ModelState.IsValid) { return(View("Create", myOfficeModel)); } var myOffice = new ExtraFee { IsDeleted = false, AmountFrom = myOfficeModel.AmountFrom, AmountTo = myOfficeModel.AmountTo, ExtraFeeName = myOfficeModel.ExtraFeeName, Cost = myOfficeModel.Cost }; using (UnitOfWork) { Repository.Insert(myOffice); } } else //Edit user { if (!ModelState.IsValid) { return(View("Edit", myOfficeModel)); } var myOffice = Repository.GetById(myOfficeModel.ExtraFeeId); myOffice.ExtraFeeName = myOfficeModel.ExtraFeeName; myOffice.AmountFrom = myOfficeModel.AmountFrom; myOffice.AmountTo = myOfficeModel.AmountTo; myOffice.Cost = myOfficeModel.Cost; using (UnitOfWork) { Repository.Update(myOffice); } } //Save success this.SetSuccessNotification(string.Format("{0} đã được lưu thành công.", "Phí phụ thêm")); return(RedirectToAction("Index", new { area = "Administrator" })); }
public ActionResult Create() { var model = new ExtraFeeModel(); return(View(model)); }