public async Task <IActionResult> Put(Contact contact) { try { // TODO: Add insert logic here if (!ModelState.IsValid || string.IsNullOrEmpty(contact.Id)) { return(BadRequest("Not a valid model")); } await Repository.UpdateItemAsync(contact.Id, contact); } catch (Exception e) { Logger.LogError(e.ToString()); throw e; } return(Ok()); }
public async Task <ActionResult> Edit(Contact contact) { try { if (ModelState.IsValid) { // TODO: Add update logic here await Repository.UpdateItemAsync(contact.Id, contact); return(RedirectToAction(nameof(Index))); } else { throw new Exception(); } } catch { ViewBag.Error = "Unable to edit record."; ViewBag.Area = Constants.LeadArea; return(View(contact)); } }