public ActionResult Create(InteractionCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = new InteractionService(); service.CreateInteraction(model); return(RedirectToAction("Index")); }
public IHttpActionResult Post(InteractionCreate interaction) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var service = CreateInteractionService(); if (!service.CreateInteraction(interaction)) { return(InternalServerError()); } return(Ok()); }
// CREATE INTERACTION public bool InteractionCreate(InteractionCreate model) { var entity = new Interaction() { OwnerId = _userId, EventId = model.EventId, CustomerId = model.CustomerId, InteractionNotes = model.InteractionNotes, InteractionPointValue = model.PointValue, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Interactions.Add(entity); return(ctx.SaveChanges() == 1); } }
public bool CreateInteraction(InteractionCreate model) { var entity = new Interaction() { LeadID = model.LeadID, RepID = model.RepID, TypeOfContact = model.TypeOfContact, Description = model.Description, CreatedUtc = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Interactions.Add(entity); return(ctx.SaveChanges() == 1); } }
public ActionResult Create(InteractionCreate model) { if (!ModelState.IsValid) { return(View(model)); } var service = CreateInteractionService(); if (service.InteractionCreate(model)) { int points = model.PointValue; service.AddPointsToCustomer(points, model.CustomerId); TempData["SaveResult"] = "Interaction recorded and points added!"; return(RedirectToAction("Index")); } ; ModelState.AddModelError("", "Interaction could not be recorded."); return(View(model)); }