public async Task <IActionResult> AddBranchOffice(BranchOfficeForm branchOffices) { BranchOffices bo = new BranchOffices() { Name = branchOffices.Name, Address = branchOffices.Address, City = branchOffices.City, Telephone = branchOffices.Telephone.ToString() }; CarCompany carCompany = new CarCompany(); carCompany = context.Carcompanies.Find(branchOffices.IdCompany); bo.Id_company = carCompany; context.BranchOffices.Add(bo); await context.SaveChangesAsync(); context.Entry(carCompany).State = EntityState.Modified; return(Ok()); }
public ActionResult Edit(int id) { var shop = _branchOfficeService.GetById(id); var shopForm = BranchOfficeForm.FromBranchOffice(shop); return(View(shopForm)); }
public ActionResult Create() { var shopForm = new BranchOfficeForm(); shopForm.ShopName = _currentUser.Shop.Name; return(View(shopForm)); }
public ActionResult Edit(int id, BranchOfficeForm shopForm) { if (!ModelState.IsValid) { return(View(shopForm)); } _branchOfficeService.Edit(shopForm.ToBranchOffice()); return(RedirectToAction("Index", new { shopId = shopForm.ShopId }).WithSuccess("Sucursal Editada")); }
public ActionResult Create(BranchOfficeForm shopForm) { if (!ModelState.IsValid) { return(View(shopForm)); } var shop = shopForm.ToBranchOffice(); shop.ShopId = _currentUser.Shop.Id; _branchOfficeService.Create(shop); return(RedirectToAction("Index", new { shopId = shopForm.ShopId }).WithSuccess("Sucursal Creada")); }
public async Task <ActionResult <BranchOfficeForm> > GetBranchOffice(int id) { var bo = await context.BranchOffices.FindAsync(id); BranchOfficeForm bof = new BranchOfficeForm() { Name = bo.Name, City = bo.City, Address = bo.Address, Id = bo.Id.ToString(), Telephone = Int32.Parse(bo.Telephone) }; if (bo == null) { return(NotFound()); } return(bof); }
public async Task <IActionResult> UpdateBranchOffice(BranchOfficeForm branchOffices) { BranchOffices branch = new BranchOffices(); branch.Id = Int32.Parse(branchOffices.Id); branch.Name = branchOffices.Name; branch.Telephone = branchOffices.Telephone.ToString(); branch.Address = branchOffices.Address; branch.City = branchOffices.City; context.Entry(branch).State = EntityState.Modified; try { await context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { return(NotFound()); } return(NoContent()); }