public ActionResult Create(int id) { var model = new PaymentPeriodModel { OrderId = id, CreateDate = DateTime.Now }; return(View(model)); }
public virtual ActionResult Save(PaymentPeriodModel myOfficeModel) { if (myOfficeModel.PaymentPeriodId <= 0) //Create News { if (!ModelState.IsValid) { return(View("Create", myOfficeModel)); } var myOffice = new PaymentPeriod() { IsDeleted = false, MyOfficeId = myOfficeModel.MyOfficeId, Paid = myOfficeModel.Paid, CreateDate = DateTime.Now, CreateUserId = WorkContext.CurrentUserId, Note = myOfficeModel.Note, OrderId = myOfficeModel.OrderId }; var order = _orderRepository.GetById(myOfficeModel.OrderId); order.TotalPaid += myOfficeModel.Paid; using (UnitOfWork) { _orderRepository.Update(order); Repository.Insert(myOffice); } //Save success this.SetSuccessNotification("Đã lưu thành công."); return(RedirectToAction("Index", new { area = "Administrator" })); } else //Edit user { if (!ModelState.IsValid) { return(View("Edit", myOfficeModel)); } var myOffice = Repository.GetById(myOfficeModel.PaymentPeriodId); myOffice.Paid = myOfficeModel.Paid; myOffice.Note = myOfficeModel.Note; myOffice.CreateDate = myOfficeModel.CreateDate; using (UnitOfWork) { Repository.Update(myOffice); } } //Save success this.SetSuccessNotification("Đã được lưu thành công."); return(RedirectToAction("Index", new { area = "Administrator" })); }
public virtual ActionResult Edit(int id) { var offices = _myOfficeRepository.Search("").ToList(); var entity = Repository.GetById(id); var model = new PaymentPeriodModel() { CreateDate = entity.CreateDate, Note = entity.Note, OrderId = entity.OrderId, Paid = entity.Paid, PaymentPeriodId = entity.PaymentPeriodId }; return(View("Edit", model)); }