private async Task <ActionResult> PerformTicketAction(int ticketId, Action <Ticket> activityFn, TicketActivity activity) { var ticket = await Context.Tickets.FindAsync(ticketId); TryValidateModel(ticket); if (ModelState.IsValid) { try { ticket.PerformAction(activityFn); } catch (SecurityException ex) { ModelState.AddModelError("Security", ex); } var result = await Context.SaveChangesAsync(); //save changes catches lastupdatedby and date automatically if (result > 0) { return(new EmptyResult());//standard success case } } //fail case, return the view and let the client/view sort out the errors ViewBag.CommentRequired = activity.IsCommentRequired(); ViewBag.Activity = activity; ViewBag.IsEditorDefaultHtml = Context.TicketDeskSettings.ClientSettings.GetDefaultTextEditorType() == "summernote"; return(PartialView("_ActivityForm", ticket)); }
public async Task <ActionResult> LoadActivity(TicketActivity activity, int ticketId, Guid?tempId) { var ticket = await Context.Tickets.FindAsync(ticketId); Context.TicketActions.IsTicketActivityValid(ticket, activity); ViewBag.CommentRequired = activity.IsCommentRequired(); ViewBag.Activity = activity; ViewBag.TempId = tempId ?? Guid.NewGuid(); return(PartialView("_ActivityForm", ticket)); }
public async Task<ActionResult> LoadActivity(TicketActivity activity, int ticketId, Guid? tempId) { var ticket = await Context.Tickets.FindAsync(ticketId); Context.TicketActions.IsTicketActivityValid(ticket, activity); ViewBag.CommentRequired = activity.IsCommentRequired(); ViewBag.Activity = activity; ViewBag.TempId = tempId ?? Guid.NewGuid(); ViewBag.IsEditorDefaultHtml = Context.TicketDeskSettings.ClientSettings.GetDefaultTextEditorType() == "summernote"; if (activity == TicketActivity.EditTicketInfo) { await SetProjectInfoForModel(ticket); } return PartialView("_ActivityForm", ticket); }
public async Task <ActionResult> LoadActivity(TicketActivity activity, int ticketId, Guid?tempId) { var ticket = await Context.Tickets.FindAsync(ticketId); Context.TicketActions.IsTicketActivityValid(ticket, activity); ViewBag.CommentRequired = activity.IsCommentRequired(); ViewBag.Activity = activity; ViewBag.TempId = tempId ?? Guid.NewGuid(); ViewBag.IsEditorDefaultHtml = Context.TicketDeskSettings.ClientSettings.GetDefaultTextEditorType() == "summernote"; if (activity == TicketActivity.EditTicketInfo) { await SetProjectInfoForModelAsync(ticket); } return(PartialView("_ActivityForm", ticket)); }
private async Task<ActionResult> PerformTicketAction(int ticketId, Action<Ticket> activityFn, TicketActivity activity) { var ticket = await Context.Tickets.FindAsync(ticketId); TryValidateModel(ticket); if (ModelState.IsValid) { try { ticket.PerformAction(activityFn); } catch (SecurityException ex) { ModelState.AddModelError("Security", ex); } var result = await Context.SaveChangesAsync(); //save changes catches lastupdatedby and date automatically if (result > 0) { return new EmptyResult();//standard success case } } //fail case, return the view and let the client/view sort out the errors ViewBag.CommentRequired = activity.IsCommentRequired(); ViewBag.Activity = activity; ViewBag.IsEditorDefaultHtml = Context.TicketDeskSettings.ClientSettings.GetDefaultTextEditorType() == "summernote"; return PartialView("_ActivityForm", ticket); }