public async Task <IActionResult> Edit(string id, [Bind("Name,CityId,Address,PhoneNumber,ContactPerson,Owner,VatRegistrationId,Bulstat,Email,BIC,IBAN,Id")] EditClientCompanyBindingModel clientCompany) { if (id != clientCompany.Id) { return(NotFound()); } if (ModelState.IsValid) { try { var currentCompany = mapper.Map <ClientCompany>(clientCompany); _context.Update(currentCompany); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!service.ClientCompanyExists(clientCompany.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CityId"] = new SelectList(service.GetAllCitiesAsync().Result, "Id", "Name", clientCompany.CityId); ViewData["VatRegistrationId"] = new SelectList(service.GetAllVatSufixesAsync().Result, "Id", "Name", clientCompany.VatRegistrationId); return(View(clientCompany)); }
public async Task <IActionResult> Edit(string id, [Bind("Brand,Model,Code,ItemTypeId,ColorId,Price,Quantity,Id,CreatedOn,ModifiedOn,IsDeleted,DeletedOn")] Item item) { if (id != item.Id) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(item); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!service.ItemExists(item.Id)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["ColorId"] = new SelectList(service.GetAllItemColorsAsync().Result, "Id", "Name", item.ColorId); ViewData["ItemTypeId"] = new SelectList(service.GetAllItemTypesAsync().Result, "Id", "Name", item.ItemTypeId); return(View(item)); }