using Neo.Afx.ComponentModel; using Neo.Afx.Mvc; using Neo.Afx.Security; using Neo.Afx.Services.Integration; using Neo.Afx.Services.Notifications.Entities; using Neo.Afx.Services.Workflows.Entities; using Neo.Afx.ViewModels; using Neo.LegitimateLicences.NewRouteRequest.Models.Database; using Neo.LegitimateLicences.Common; using Neo.LegitimateLicences.Common.Helpers; using Neo.LegitimateLicences.Data.Models; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; namespace Neo.LegitimateLicences.NewRouteRequest { public partial class NewRouteRequestController { #region Form public ActionResult Form() { 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.NewRouteRequestDetails, itemId, taskId, Profile.UserID); } if (activeUserTask == null) { activeUserTask = WorkflowHelper.GetActiveUserTask(Profile.UserID, EntityEnum.NewRouteRequestDetails, itemId); } #endregion var model = new NewRouteRequestFormModel { UserSecurables = (Profile.Securables != null) ? Profile.Securables.ToList() : new List(), Ui = new WorkflowConsoleUIProperties() { canSave = (activeUserTask != null && (activeUserTask.WorkflowTemplateStepTypeID == (short)WorkflowTemplateStepTypeEnum.DataCapture)) } }; var db = new NewRouteDatabase(); model.Data = db.GetNewRouteRequestForm(itemId, Profile.UserID); model.Lookups = GetLookupsForFormGetLookupsFormView(); var workflowInstance = WorkflowHelper.GetWorkflowInstanceView(WebHelper.EntityID, WebHelper.ItemID, Profile.UserID); model.WorkflowInstance = workflowInstance; model.CTS = workflowInstance.StepNumber; return View("Form", model); } #endregion #region GetLookups public List GetLookupsForFormGetLookupsFormView() { var lookups = new List(); var integrationStore = new SqlIntegrationStore(); try { integrationStore.Open(); lookups.Add(new LookupList("NodeWaypointTypes", integrationStore.GetDataEntities("WaypointTypes", string.Empty))); } finally { integrationStore.Close(); } return lookups; } #endregion } }