using Neo.LegitimateLicences.Common; using Neo.LegitimateLicences.Common.Helpers; using System.Web.Mvc; using System.Linq; using System.Collections.Generic; using Neo.Afx.Security; using Neo.LegitimateLicences.ApplicationRequest.Models.Database; using Neo.Afx.Services.Workflows.Entities; namespace Neo.LegitimateLicences.ApplicationRequest { public partial class ApplicationRequestController : Controller { #region Constructor public ApplicationRequestController() : base(new ApplicationDatabase()) { } #endregion #region Console public ActionResult Console() { var isNew = WebHelper.ItemID == -1; var itemId = WebHelper.ItemID; var taskId = WebHelper.TaskID; #region Get active user task Vw_WorkflowInstanceTask activeUserTask = null; if (taskId != -1) { activeUserTask = WorkflowHelper.GetActiveUserUserTaskByID((long)EntityEnum.ApplicationRequestDetails, itemId, taskId, Profile.UserID); } if (activeUserTask == null) { activeUserTask = WorkflowHelper.GetActiveUserTask(Profile.UserID, EntityEnum.ApplicationRequestDetails, itemId); } #endregion var model = new ApplicationRequestConsoleModel { UserSecurables = (Profile.Securables != null) ? Profile.Securables.ToList() : new List(), Ui = new Afx.ViewModels.WorkflowConsoleUIProperties() }; if (!isNew) { model.ApplicationView = Database.GetApplicationView(WebHelper.ItemID, Profile.UserID); model.WorkflowInstance = WorkflowHelper.GetWorkflowInstanceView(WebHelper.EntityID, WebHelper.ItemID, Profile.UserID); if(model.ApplicationView.CopiedFromApplicationDetailID != null) { model.ParentApplicationView = Database.GetApplicationView(model.ApplicationView.CopiedFromApplicationDetailID.Value, Profile.UserID); } else { model.ParentApplicationView = new Vw_ApplicationDetails_Light(); } model.SetFormEditState(activeUserTask); model.Ui.canSubmit = (activeUserTask != null && activeUserTask.WorkflowTemplateStepTypeID == (short)WorkflowTemplateStepTypeEnum.DataCapture); model.Ui.canApproveReject = (activeUserTask != null && activeUserTask.WorkflowTemplateStepTypeID == (short)WorkflowTemplateStepTypeEnum.Approval); model.Ui.canRequestCorrection = (activeUserTask != null && activeUserTask.WorkflowTemplateStepNumber > 1); model.Ui.canDelete = (activeUserTask != null); model.Ui.canEscalate = (activeUserTask != null && activeUserTask.WorkflowTemplateStepNumber == 1); model.Ui.canSendEscalationBack = false; if (activeUserTask != null) { if (activeUserTask.EscalatedFromID != null) { model.Ui.canSendEscalationBack = true; } } } return View("Console", model); } #endregion } }