public IHttpActionResult Put(InteractionEdit interaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateInteractionService(); if (!service.UpdateInteraction(interaction)) { return(InternalServerError()); } return(Ok()); }
public bool UpdateInteraction(InteractionEdit model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Interactions .Single(e => e.InteractionID == model.InteractionID); entity.TypeOfContact = model.TypeOfContact; entity.Description = model.Description; entity.ModifiedUtc = DateTimeOffset.Now; return(ctx.SaveChanges() == 1); } }
public ActionResult Edit(int id) { var service = new InteractionService(); var detail = service.GetInteractionById(id); var model = new InteractionEdit { InteractionID = detail.InteractionID, TypeOfContact = detail.TypeOfContact, Description = detail.Description, ModifiedUtc = DateTimeOffset.Now }; return(View(model)); }
// EDIT AN INTERACTION public bool UpdateInteraction(InteractionEdit Model) { using (var ctx = new ApplicationDbContext()) { var entity = ctx .Interactions .Single(e => e.InteractionId == Model.InteractionId && e.OwnerId == _userId); entity.InteractionNotes = Model.InteractionNotes; entity.InteractionPointValue = Model.InteractionPointValue; entity.CustomerId = Model.CustomerId; entity.EventId = Model.EventId; entity.ModifiedUtc = DateTime.Now; return(ctx.SaveChanges() == 1); } }
// public ActionResult Edit(int id) { var service = CreateInteractionService(); var detail = service.GetInteractionById(id); ViewBag.CustomerId = GetListOfCustomers(); ViewBag.EventId = GetListOfEvents(); var model = new InteractionEdit { CustomerId = detail.CustomerId, EventId = detail.EventId, InteractionId = detail.InteractionId, InteractionNotes = detail.InteractionNotes, InteractionPointValue = detail.InteractionPointValue }; return(View(model)); }
public ActionResult Edit(int id, InteractionEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.InteractionId != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = CreateInteractionService(); if (service.UpdateInteraction(model)) { TempData["SaveResult"] = "Your Interaction was updated."; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Your Interaction could not be updated."); return(View()); }
public ActionResult Edit(int id, InteractionEdit model) { if (!ModelState.IsValid) { return(View(model)); } if (model.InteractionID != id) { ModelState.AddModelError("", "Id Mismatch"); return(View(model)); } var service = new InteractionService(); if (service.UpdateInteraction(model)) { TempData["SaveResult"] = "Interaction Details Successfully Updated"; return(RedirectToAction("Index")); } ModelState.AddModelError("", "Failed to Update Interaction"); return(View(model)); }