public ActionResult Edit()
        {
            // Retrieve ID from session
            string code = sessionManager.OrganisationTypeCode;

            OrganisationTypeVM model = new OrganisationTypeVM();

            // Not from staff or error
            if (String.IsNullOrEmpty(code))
            {
                //If session has lists then use them
                RepopulateListsFromCacheSession(model);

                //Assume we are in create mode as no code passed
                model.OrganisationTypeItem = new OrganisationTypeModel()
                {
                    IsActive = true
                };
            }
            //if we have been passed a code then assume we are in edit situation and we need to retrieve from the database.
            else
            {
                // Create service instance
                IUcbService sc = UcbService;

                try
                {
                    // Call service to get OrganisationType item and any associated lookups
                    OrganisationTypeVMDC returnedObject = sc.GetOrganisationType(CurrentUser, CurrentUser, appID, "", code);

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    //Get view model from service
                    model = ConvertOrganisationTypeDC(returnedObject);

                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    //Store the service version
                    sessionManager.OrganisationTypeServiceVersion = model.OrganisationTypeItem;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            //Adds current retrieved OrganisationType to session
            sessionManager.CurrentOrganisationType = model.OrganisationTypeItem;
            SetAccessContext(model);

            return(View(model));
        }
        public ActionResult SiteOrganisationSearch(int page = 1)
        {
            //Create model
            OrganisationSearchVM model = new OrganisationSearchVM();

            //Repopulate search criteria if already entered
            if (null == model.SearchCriteria && sessionManager.OrganisationSearchCriteria != null)
            {
                model.SearchCriteria = sessionManager.OrganisationSearchCriteria;
            }
            else
            {
                // Add criteria to search only on Organisation Type  of Site
                model.SearchCriteria = new OrganisationSearchCriteriaModel();
                model.SearchCriteria.OrganisationType = "Site";
            }

            // Create service instance
            IUcbService sc = UcbService;

            try
            {
                // Convert search criteria to data contract
                OrganisationSearchCriteriaDC organisationSearch = Mapper.Map <OrganisationSearchCriteriaDC>(model.SearchCriteria);

                // Call service
                OrganisationSearchVMDC response = sc.SearchOrganisation(CurrentUser, CurrentUser, appID, "", organisationSearch, page, PageSize, true);

                // Close service communication
                ((ICommunicationObject)sc).Close();

                //Map response back to view model
                model.MatchList = Mapper.Map <IEnumerable <OrganisationSearchMatchDC>, List <OrganisationSearchMatchModel> >(response.MatchList);

                // Set paging values
                model.TotalRows  = response.RecordCount;
                model.PageSize   = sessionManager.PageSize;
                model.PageNumber = page;

                // Store the page number we were on
                sessionManager.OrganisationPageNumber = model.PageNumber;

                return(View(model));
            }
            catch (Exception e)
            {
                // Handle the exception
                string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                model.Message = message;

                return(View(model));
            }
        }
Esempio n. 3
0
        public ActionResult Edit()
        {
            // Retrieve ID from session
            string organisationCode = sessionManager.IsExpected(sessionManager.OrganisationCode);

            SiteVM model = null;

            // Create service instance
            IUcbService sc = UcbService;

            try
            {
                // Call service to get Site item and any associated lookups via Organisation code
                SiteVMDC returnedObject = sc.GetSiteByOrganisationCode(CurrentUser, CurrentUser, appID, "", organisationCode);

                // Close service communication
                ((ICommunicationObject)sc).Close();

                //Get view model from service
                model = ConvertSiteDC(returnedObject);

                ResolveFieldCodesToFieldNamesUsingLists(model);

                // Store the service version
                sessionManager.SiteServiceVersion = model.SiteItem;
            }
            catch (Exception e)
            {
                // Handle the exception
                string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                model.Message = message;

                return(View(model));
            }



            //Adds current retrieved Site to session
            sessionManager.CurrentSite = model.SiteItem;
            sessionManager.SiteNominatedManagersSearch       = model.NominatedManagerSearchList;
            sessionManager.SiteDeputyNominatedManagersSearch = model.DeputyNominatedManagerSearchList;
            sessionManager.SiteDeputyNominatedManagers       = model.DeputyNominatedManagerList;

            SetAccessContext(model);

            return(View(model));
        }
Esempio n. 4
0
        public ActionResult SearchStaffDeputyNominatedManagers()
        {
            // Get the updated model
            var model = GetUpdatedModel();

            // Clear model state to prevent validation
            ModelState.Clear();

            //Set flags false
            SetFlagsFalse(model);

            // Create service instance
            IUcbService sc = UcbService;

            try
            {
                StaffNominatedManagerSearchVMDC searchCritera = new StaffNominatedManagerSearchVMDC();
                searchCritera.FirstName = model.DeputyNominatedManagerFirstNameSearch;
                searchCritera.LastName  = model.DeputyNominatedManagerLastNameSearch;
                searchCritera.IsDeputyNominatedManager = true;
                searchCritera.IsNominatedManager       = false;

                StaffNominatedManagerSearchVMDC response = sc.SearchStaffNominatedManagers(CurrentUser, CurrentUser, appID, "", searchCritera);

                // Close service communication
                ((ICommunicationObject)sc).Close();

                //Map response back to view model
                model.DeputyNominatedManagerSearchList = Mapper.Map <List <StaffModel> >(response.MatchList);

                //Adds current retrieved Site to session
                sessionManager.CurrentSite = model.SiteItem;
                sessionManager.SiteNominatedManagersSearch       = model.NominatedManagerSearchList;
                sessionManager.SiteDeputyNominatedManagersSearch = model.DeputyNominatedManagerSearchList;
                sessionManager.SiteDeputyNominatedManagers       = model.DeputyNominatedManagerList;

                return(View(model));
            }
            catch (Exception e)
            {
                // Handle the exception
                string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                model.Message = message;

                return(View(model));
            }
        }
        public ActionResult SiteOrganisationSearchCriteriaPost(OrganisationSearchVM model, int page = 1)
        {
            // Add Organisation Type search to ensure we only search within Site
            model.SearchCriteria.OrganisationType = "Site";

            // Create service instance
            IUcbService sc = UcbService;

            try
            {
                // Convert search criteria to data contract
                OrganisationSearchCriteriaDC organisationSearch = Mapper.Map <OrganisationSearchCriteriaDC>(model.SearchCriteria);

                // Call service
                OrganisationSearchVMDC response = sc.SearchOrganisation(CurrentUser, CurrentUser, appID, "", organisationSearch, page, PageSize, true);

                // Close service communication
                ((ICommunicationObject)sc).Close();

                //Map response back to view model
                model.MatchList = Mapper.Map <IEnumerable <OrganisationSearchMatchDC>, List <OrganisationSearchMatchModel> >(response.MatchList);

                // Set paging values
                model.TotalRows  = response.RecordCount;
                model.PageSize   = sessionManager.PageSize;
                model.PageNumber = page;

                // Store the page number we were on
                sessionManager.OrganisationPageNumber     = model.PageNumber;
                sessionManager.OrganisationSearchCriteria = model.SearchCriteria;

                return(View("SiteOrganisationSearch", model));
            }
            catch (Exception e)
            {
                // Handle the exception
                string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                model.Message = message;

                return(View("SiteOrganisationSearch", model));
            }
        }
Esempio n. 6
0
        public ActionResult Search(string nino)
        {
            IntranetStaffProtectionVM model = new IntranetStaffProtectionVM();

            if (ModelState.IsValid)
            {
                model.NINO = nino;

                // Create service instance
                IUcbService sc = UcbService;

                // Create model

                try
                {
                    IntranetStaffProtectionResult response = sc.IntranetStaffProtection(CurrentUser, CurrentUser, appID, "", model.NINO);

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    //Map response back to view model
                    model.StaffProtectionList = Mapper.Map <IntranetStaffProtectionResult, IntranetStaffProtectionModel>(response);


                    if (response.ControlMeasures == null)
                    {
                        model.Message = Resources.LABEL_ISP_No_data_found;
                    }

                    return(View(model));
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;
                }
            }
            return(View(model));
        }
Esempio n. 7
0
        public ActionResult Search(int page = 1)
        {
            // Create service instance
            IUcbService sc = UcbService;

            // Create model
            CustomerSearchVM model = new CustomerSearchVM();

            try
            {
                CustomerSearchVMDC response = sc.SearchCustomer(CurrentUser, CurrentUser, appID, "", null, page, PageSize);

                // Close service communication
                ((ICommunicationObject)sc).Close();

                //Map response back to view model
                model.MatchList = Mapper.Map <IEnumerable <CustomerSearchMatchDC>, List <CustomerSearchMatchModel> >(response.MatchList);

                // Set paging values
                model.TotalRows  = response.RecordCount;
                model.PageSize   = sessionManager.PageSize;
                model.PageNumber = page;

                // Store the page number we were on
                sessionManager.CustomerPageNumber = model.PageNumber;

                return(View(model));
            }
            catch (Exception e)
            {
                // Handle the exception
                string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                model.Message = message;

                return(View(model));
            }
        }
Esempio n. 8
0
 public IntranetStaffProtectionController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 9
0
 public NarrativeController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 10
0
        //This method is shared between create and save
        private ActionResult UpdateCustomer()
        {
            // Get the updated model
            var model = GetUpdatedModel();

            // Test to see if there are any errors
            var errors = ModelState
                         .Where(x => x.Value.Errors.Count > 0)
                         .Select(x => new { x.Key, x.Value.Errors[0].ErrorMessage })
                         .ToArray();

            //Set flags false
            SetFlagsFalse(model);

            // Test to see if the model has validated correctly
            if (ModelState.IsValid)
            {
                // Create service instance
                IUcbService sc = UcbService;

                //Attempt update
                try
                {
                    // Map model to data contract
                    CustomerDC CustomerItem = Mapper.Map <CustomerDC>(model.CustomerItem);

                    CustomerVMDC returnedObject = null;

                    if (null == model.CustomerItem.Code || model.CustomerItem.Code == Guid.Empty)
                    {
                        // Call service to create new Customer item
                        returnedObject = sc.CreateCustomer(CurrentUser, CurrentUser, appID, "", CustomerItem);
                    }
                    else
                    {
                        // Call service to update Customer item
                        returnedObject = sc.UpdateCustomer(CurrentUser, CurrentUser, appID, "", CustomerItem);
                    }

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    // Retrieve item returned by service
                    var createdCustomer = returnedObject.CustomerItem;

                    // Map data contract to model
                    model.CustomerItem = Mapper.Map <CustomerModel>(createdCustomer);

                    //After creation some of the fields are display only so we need the resolved look up nmames
                    ResolveFieldCodesToFieldNamesUsingLists(model);

                    // Set access context to Edit mode
                    model.AccessContext = CustomerAccessContext.Edit;

                    // Save version of item returned by service into session
                    sessionManager.CustomerServiceVersion = model.CustomerItem;
                    sessionManager.CurrentCustomer        = model.CustomerItem;

                    // Remove the state from the model as these are being populated by the controller and the HTML helpers are being populated with
                    // the POSTED values and not the changed ones.
                    ModelState.Clear();
                    model.Message = Resources.MESSAGE_UPDATE_SUCCEEDED;
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            return(View(model));
        }
 public OrganisationTypeController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
 public IncidentCategoryController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
 public ContingencyArrangementController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
 public EventLeadingToIncidentController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
 public PublishedReportController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 16
0
 public SiteStaffController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 17
0
 public IncidentInterestedPartyController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 18
0
 public AttachmentController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 19
0
 public ADRoleLookupController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
 public ApplicationAttributeController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 21
0
 public IntroductoryInformationController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 22
0
        public ActionResult DeleteCustomer(FormCollection collection)
        {
            var model = GetUpdatedModel();

            if (model.IsDeleteConfirmed == "True")
            {
                //Set flags false
                SetFlagsFalse(model);

                model.IsDeleteConfirmed = "False";

                // Create service instance
                IUcbService sc = UcbService;

                try
                {
                    // Call service to delete the item
                    sc.DeleteCustomer(CurrentUser, CurrentUser, appID, "", model.CustomerItem.Code.ToString(), model.CustomerItem.RowIdentifier.ToString());

                    // Close service communication
                    ((ICommunicationObject)sc).Close();

                    // Remove the current values from session
                    sessionManager.CurrentCustomer        = null;
                    sessionManager.CustomerServiceVersion = null;

                    // Remove the state from the model as these are being populated by the controller and the HTML helpers are being populated with
                    // the POSTED values and not the changed ones.
                    ModelState.Clear();

                    // Create new item but keep any lists
                    model.CustomerItem = new CustomerModel();

                    // Set message to return to user
                    model.Message = Resources.MESSAGE_DELETE_SUCCEEDED;

                    // Set access context to Edit mode
                    model.AccessContext = CustomerAccessContext.Create;

                    // Redirect to the search screen
                    return(View(model));
                }
                catch (Exception e)
                {
                    // Handle the exception
                    string message = ExceptionManager.HandleException(e, (ICommunicationObject)sc);
                    model.Message = message;

                    return(View(model));
                }
            }
            else
            {
                //Set flags false
                SetFlagsFalse(model);
                model.Message           = Resources.MESSAGE_DELETECONFIRMATION;
                model.IsDeleteConfirmed = "True";
            }

            return(View(model));
        }
 public IncidentSystemMarkedController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 24
0
 public CustomerController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }
Esempio n. 25
0
 public SystemParameterController(IUcbService UcbService, ISessionManager sessionManager, ICacheManager cacheManager)
     : base(sessionManager, cacheManager)
 {
     this.UcbService = UcbService;
 }