public async Task <IActionResult> Create([Bind("OwnerId,OwnerPassportNo,FullName,PhoneNumber,City,Street")] PrivateOwner privateOwner) { if (ModelState.IsValid) { int result = await _service.Create(privateOwner); if (result == 0) { ViewData["BackController"] = "PrivateOwners"; ViewData["BackAction"] = "Index"; ViewData["ErrorMessage"] = "Form data has been lost. Database refused your request. Contact sysadmin."; return(View("DbUpdateError")); } return(RedirectToAction("Index")); } return(View(privateOwner)); }
public async Task <int> Edit(int id, PrivateOwner owner) { try { _context.Update(owner); return(await _context.SaveChangesAsync()); } catch (DbUpdateConcurrencyException) { if (!PrivateOwnerExists(id)) { return(0); } else { throw; } } }
public async Task <IActionResult> Edit(int id, [Bind("OwnerId,OwnerPassportNo,FullName,PhoneNumber,City,Street")] PrivateOwner privateOwner) { if (id != privateOwner.OwnerId) { return(NotFound()); } if (ModelState.IsValid) { int result = await _service.Edit(id, privateOwner); if (result == 0) { ViewData["BackController"] = "PrivateOwners"; ViewData["BackAction"] = "Index"; ViewData["ErrorMessage"] = "Entity which you tried to modify doesn't exist anymore"; return(View("DbUpdateError")); } return(RedirectToAction("Index")); } return(View(privateOwner)); }
// POST: PrivateOwners/Edit/5 public async Task <int> Edit(int id, PrivateOwner client) { return(await _repository.Edit(id, client)); }
public async Task <int> Create(PrivateOwner client) { return(await _repository.Create(client)); }
public async Task <int> Create(PrivateOwner owner) { _context.Add(owner); return(await _context.SaveChangesAsync()); }