private bool DoTicketActivity(string activityName, Ticket ticket, string comments, params object[] args) { //TODO: The methods called on the ticket service are supplying the user name, but the ticket service has a reference to security service and can infer that bool result = false; switch (activityName) { case "AddComment": result = Tickets.AddCommentToTicket(ticket, comments); break; case "SupplyMoreInfo": bool markActive = (bool)args[0]; result = Tickets.SupplyMoreInfoForTicket(ticket, comments, markActive); break; case "RequestMoreInfo": result = Tickets.RequestMoreInfoForTicket(ticket, comments); break; case "CancelMoreInfo": result = Tickets.CancelMoreInfoForTicket(ticket, comments); break; case "TakeOver": string tpriority = (args != null && args.Length == 1) ? args[0] as string : null; result = Tickets.TakeOverTicket(ticket, comments, tpriority); break; case "Assign": string assignTo = (args != null && args.Length > 0) ? args[0] as string : null; string apriority = (args != null && args.Length > 1) ? args[1] as string : null; result = Tickets.AssignTicket(ticket, comments, assignTo, apriority); break; case "Resolve": result = Tickets.ResolveTicket(ticket, comments); break; case "Close": result = Tickets.CloseTicket(ticket, comments, false); break; case "ForceClose": result = Tickets.CloseTicket(ticket, comments, true); break; case "GiveUp": result = Tickets.GiveUpTicket(ticket, comments); break; case "ReOpen": bool?assignToMe = (args != null && args.Length > 0) ? args[0] as bool? : false; bool?ownedByMe = (args != null && args.Length > 1) ? args[1] as bool? : false; if (!assignToMe.HasValue) { assignToMe = false; } if (!ownedByMe.HasValue) { ownedByMe = false; } if (!Security.IsTdStaff()) { if (ticket.Owner != Security.CurrentUserName) { ownedByMe = true; } } result = Tickets.ReOpenTicket(ticket, comments, assignToMe.Value, ownedByMe.Value); break; case "ModifyAttachments": var attachments = args[0] as List <TicketAttachment>; result = Tickets.ModifyAttachmentsForTicket(ticket, comments, attachments); //TODO: on successful result we need to remove the pending files. The model has no notion of "pending files" though so this needs to be done seperately break; case "EditTicketInfo": result = Tickets.EditTicketDetails(ticket, comments); break; } return(result); }