public IActionResult Edit(int invoiceId, int houseId) { Invoice invoice = _invoiceService.GetById(invoiceId); if (invoice == null) { return(RedirectToAction("Index", new { id = houseId })); } var invoiceEditVModel = new InvoiceEditViewModel { HouseAddress = (GetAddress(houseId).Item1), Invoice = new InvoiceViewModel { InvoiceDate = invoice.InvoiceDate, Amount = invoice.Amount, DatePaid = invoice.DatePaid, IsPaid = invoice.IsPaid, Description = invoice.Description, InvoiceId = invoice.InvoiceId, HouseId = invoice.HouseId } }; return(View(invoiceEditVModel)); }
public InvoiceEditViewModel Update(InvoiceEditViewModel P) { Invoice PP = InvoiceRepo.Update(P.ToModel()); unitOfWork.Commit(); return(PP.ToEditableViewModel()); }
public ResultViewModel <InvoiceEditViewModel> Update(InvoiceEditViewModel emp) { ResultViewModel <InvoiceEditViewModel> result = new ResultViewModel <InvoiceEditViewModel>(); try { if (!ModelState.IsValid) { result.Message = "In Valid Model State"; } else { InvoiceEditViewModel selectedEmp = InvoiceService.Update(emp); result.Successed = true; result.Data = selectedEmp; } } catch (Exception ex) { result.Successed = false; result.Message = "Semething Went Wrong"; } return(result); }
// GET: Invoices/Edit/5 public async Task <IActionResult> Edit(int?id) { if (id == null) { return(NotFound()); } var invoice = await _bll.Invoices.FindAsync(id); if (invoice == null) { return(NotFound()); } var vm = new InvoiceEditViewModel(); vm.Invoice = invoice; vm.AppUserSelectList = new SelectList(await _bll.AppUsers.AllAsync(), nameof(BLL.App.DTO.Identity.AppUser.Id), nameof(BLL.App.DTO.Identity.AppUser.Id), invoice.AppUserId); return(View(vm)); }
private async System.Threading.Tasks.Task AddInvoices(InvoiceEditViewModel invoiceEditViewModel) { var page = new InvoiceEditPage(); page.BindingContext = invoiceEditViewModel; await Navigation.PushAsync(page); NavigationPage.SetHasBackButton(page, true); }
public InvoiceEditViewModel Add(InvoiceEditViewModel P) { Invoice PP = InvoiceRepo.Add(P.ToModel()); foreach (var item in P.InvoiceItems) { item.InvoiceID = PP.ID; InvoiceItemRepo.Add(item.ToModel()); } unitOfWork.Commit(); return(PP.ToEditableViewModel()); }
public async Task <IActionResult> Edit(InvoiceEditViewModel input) { if (!this.ModelState.IsValid) { var viewModel = await this.invoicesService.GetDetailsAsync <InvoiceEditViewModel>(input.Id); return(this.View(viewModel)); } await this.invoicesService.EditAsync(input.Id, input.Number, input.Date, input.CarFuelType, input.Location, input.CurrentLiters, input.Price, input.Quantity, input.TotalPrice, input.UserId, input.CarId, input.CreatedBy, input.CreatedOn, input.ModifiedBy); return(this.RedirectToAction("All", "Invoices", new { id = input.CarId })); }
public async Task <IActionResult> Edit(InvoiceEditViewModel input) { if (!this.ModelState.IsValid) { var viewModel = await this.invoicesService.GetDetailsAsync <InvoiceEditViewModel>(input.Id); viewModel.AllDrivers = this.usersService.GetAll(viewModel.CarCompanyId); return(this.View(viewModel)); } var user = await this.usersService.GetByNameAsync <UserViewModel>(input.ApplicationUserFullName, input.CarCompanyId); await this.invoicesService.EditAsync(input.Id, input.Number, input.Date, input.CarFuelType, input.Location, input.CurrentLiters, input.Price, input.Quantity, input.TotalPrice, user.Id, input.CarId, input.CreatedBy, input.CreatedOn, input.ModifiedBy); return(this.RedirectToAction("All", "Invoices", new { id = input.CarId })); }
public IActionResult Edit(InvoiceEditViewModel invoiceVM) { if (invoiceVM == null) { ModelState.AddModelError("", "no invoice object has been passed!"); } if (ModelState.IsValid) { _invoiceService.Edit(invoiceVM.Invoice.InvoiceId, invoiceVM.Invoice.HouseId, invoiceVM.Invoice.InvoiceDate, invoiceVM.Invoice.Amount, invoiceVM.Invoice.Description, invoiceVM.Invoice.IsPaid, invoiceVM.Invoice.DatePaid); TempData.Add("ResultMessage", String.Format("Invoice for {0} edited successfully!", invoiceVM.HouseAddress)); return(RedirectToAction("Index", new { id = invoiceVM.Invoice.HouseId })); } return(View(invoiceVM)); }
public async Task <IActionResult> Edit(int id, InvoiceEditViewModel vm) { if (id != vm.Invoice.Id) { return(NotFound()); } if (ModelState.IsValid) { _bll.Invoices.Update(vm.Invoice); await _bll.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } vm.AppUserSelectList = new SelectList(await _bll.AppUsers.AllAsync(), nameof(BLL.App.DTO.Identity.AppUser.Id), nameof(BLL.App.DTO.Identity.AppUser.Id), vm.Invoice.AppUserId); return(View(vm)); }
// GET: Invoices/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } // opzoeken van de juiste quotation Invoice invoice = db.Invoices.Find(id); // alle klantgegevens ophalen van de offerte var customer = db.Customers.Find(invoice.CustomerId); // info opzoeken van het werfadres Address werfadres = new Address(); werfadres.Box = invoice.customerDeliveryAddress.Box; werfadres.PostalCodeNumber = invoice.customerDeliveryAddress.PostalCodeNumber; werfadres.StreetName = invoice.customerDeliveryAddress.StreetName; werfadres.StreetNumber = invoice.customerDeliveryAddress.StreetNumber; werfadres.Town = invoice.customerDeliveryAddress.Town; // vullen van viewmodel InvoiceEditViewModel ievm = new InvoiceEditViewModel(); ievm.invoice = invoice; ievm.customer = customer; ievm.address = werfadres; if (invoice == null) { return(HttpNotFound()); } // omgezet naar model //ViewBag.CustomerId = new SelectList(db.Customers, "CustomerId", "FullName"); //var quotDetList = from q in db.QuotationDetails select q; //quotDetList = quotDetList.Where(q => q.QuotationId == id); //ViewBag.QuotationDetail = quotDetList.ToList(); return(View(ievm)); }