Exemplo n.º 1
0
        public ActionResult Index()
        {
            IntroductoryInformationVM model = new IntroductoryInformationVM();

            // Create service instance
            UcbServiceClient sc = new UcbServiceClient();

            try
            {
                // Get users localisation
                LanguageManager language = new LanguageManager(sessionManager);
                string          locale   = language.GetLocale();

                // Call service to get IntroductoryInformation item and any associated lookups based on locale
                IntroductoryInformationVMDC returnedObject = sc.GetIntroductoryInformationByLocale(CurrentUser, CurrentUser, appID, "", locale);

                // Close service communication
                sc.Close();

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

                ResolveFieldCodesToFieldNamesUsingLists(model);

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

                return(View(model));
            }

            if (sessionManager.PageFrom == "EditIncident" || sessionManager.PageFrom == "EditReferral")
            {
                if (!string.IsNullOrEmpty(sessionManager.MessageFromPageFrom))
                {
                    model.Message = sessionManager.MessageFromPageFrom;
                    sessionManager.MessageFromPageFrom = null;
                }
            }

            //Adds current retrieved IntroductoryInformation to session
            sessionManager.CurrentIntroductoryInformation = model.IntroductoryInformationItem;
            SetAccessContext(model);

            return(View(model));
        }
        public ActionResult MIReport()
        {
            sessionManager.PageFrom = "MIMenu";
            string             ReportCode = Request.QueryString["ReportID"];
            UcbServiceClient   sc         = new UcbServiceClient();
            StandardReportVMDC report     = null;

            try
            {
                report = sc.GetStandardReport(CurrentUser, CurrentUser, "Ucb", "", ReportCode);
                sc.Close();
            }
            catch (Exception e)
            {
                ExceptionManager.HandleException(e, sc);
            }
            sessionManager.CurrentStandardReport = Mapper.Map <StandardReportModel>(report.StandardReportItem);
            //Report Name now passed in session
            sessionManager.RequestedReport = report.StandardReportItem.ReportName;
            return(Redirect("~/Reports/Reports.aspx"));
        }
Exemplo n.º 3
0
        private IncidentLookupListsCacheObject GetIncidentAndLookups()
        {
            UcbServiceClient sc = new UcbServiceClient();

            try
            {
                // Get instance of Language Manager
                LanguageManager language = new LanguageManager();

                // Get users localisation
                string locale = language.GetLocale();

                IncidentVMDC returnObject = sc.GetIncident(HttpContext.Current.User.Identity.Name, HttpContext.Current.User.Identity.Name, "Ucb", "", null, locale);

                sc.Close();

                IncidentLookupListsCacheObject CachedLists = new IncidentLookupListsCacheObject();

                CachedLists.JobRoleList                 = Mapper.Map <IEnumerable <JobRoleDC>, List <JobRoleModel> >(returnObject.JobRoleList);
                CachedLists.ReferrerList                = Mapper.Map <IEnumerable <ReferrerDC>, List <ReferrerModel> >(returnObject.ReferrerList);
                CachedLists.StaffMemberBusinessList     = Mapper.Map <IEnumerable <OrganisationDC>, List <OrganisationModel> >(returnObject.StaffMemberBusinessList.OrderBy(x => x.Name));
                CachedLists.StaffMemberBusinessAreaList = Mapper.Map <IEnumerable <OrganisationDC>, List <OrganisationModel> >(returnObject.StaffMemberBusinessAreaList.OrderBy(x => x.Name));
                //***Note - have removed sites/home offices from cache***
                //CachedLists.StaffMemberHomeOfficeList = Mapper.Map<IEnumerable<OrganisationDC>, List<OrganisationModel>>(returnObject.StaffMemberHomeOfficeList);
                CachedLists.EventLeadingToIncidentList = Mapper.Map <IEnumerable <EventLeadingToIncidentDC>, List <EventLeadingToIncidentModel> >(returnObject.EventLeadingToIncidentList);
                CachedLists.IncidentLocationList       = Mapper.Map <IEnumerable <IncidentLocationDC>, List <IncidentLocationModel> >(returnObject.IncidentLocationList);
                CachedLists.IncidentCategoryList       = Mapper.Map <IEnumerable <IncidentCategoryDC>, List <IncidentCategoryModel> >(returnObject.IncidentCategoryList);
                CachedLists.IncidentTypeList           = Mapper.Map <IEnumerable <IncidentTypeDC>, List <IncidentTypeModel> >(returnObject.IncidentTypeList);
                CachedLists.IncidentDetailsList        = Mapper.Map <IEnumerable <IncidentDetailDC>, List <IncidentDetailModel> >(returnObject.IncidentDetailsList);
                CachedLists.AbuseTypeList           = Mapper.Map <IEnumerable <AbuseTypeDC>, List <AbuseTypeModel> >(returnObject.AbuseTypeList);
                CachedLists.FastTrackAttachmentList = Mapper.Map <IEnumerable <AttachmentDC>, List <AttachmentModel> >(returnObject.FastTrackAttachmentList);
                CachedLists.RIDDORAttachmentList    = Mapper.Map <IEnumerable <AttachmentDC>, List <AttachmentModel> >(returnObject.RIDDORAttachmentList);

                CachedLists.AdminEmail       = returnObject.AdminEmail;
                CachedLists.DeputyAdminEmail = returnObject.DeputyAdminEmail;

                CachedLists.RelationshipToCustomerList     = Mapper.Map <IEnumerable <RelationshipToCustomerDC>, List <RelationshipToCustomerModel> >(returnObject.RelationshipToCustomerList);
                CachedLists.ContingencyArrangementBaseList = Mapper.Map <IEnumerable <ContingencyArrangementDC>, List <ContingencyArrangementModel> >(returnObject.ContingencyArrangementList);
                CachedLists.ControlMeasureBaseList         = Mapper.Map <IEnumerable <ControlMeasureDC>, List <ControlMeasureModel> >(returnObject.ControlMeasureList);
                CachedLists.SystemMarkedBaseList           = Mapper.Map <IEnumerable <SystemMarkedDC>, List <SystemMarkedModel> >(returnObject.SystemMarkedList);
                CachedLists.InterestedPartyBaseList        = Mapper.Map <IEnumerable <InterestedPartyDC>, List <InterestedPartyModel> >(returnObject.InterestedPartyList);

                //Select Lists
                CachedLists.ContingencyArrangementList = returnObject.ContingencyArrangementList.Select(x => new SelectListItem()
                {
                    Value = x.Code.ToString(), Text = x.Description
                }).ToList();
                CachedLists.ControlMeasureList = returnObject.ControlMeasureList.Select(x => new SelectListItem()
                {
                    Value = x.Code.ToString(), Text = x.ControlMeasureDescription
                }).ToList();
                CachedLists.SystemMarkedList = returnObject.SystemMarkedList.Select(x => new SelectListItem()
                {
                    Value = x.Code.ToString(), Text = x.Description
                }).ToList();
                CachedLists.InterestedPartyList = returnObject.InterestedPartyList.Select(x => new SelectListItem()
                {
                    Value = x.Code.ToString(), Text = x.Description
                }).ToList();



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

                return(null);
            }
        }
Exemplo n.º 4
0
        public ActionResult SaveIntroductoryInformation(FormCollection collection)
        {
            // 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
                UcbServiceClient sc = new UcbServiceClient();

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

                    IntroductoryInformationVMDC returnedObject = null;

                    // Call service to update IntroductoryInformation item
                    returnedObject = sc.UpdateIntroductoryInformation(CurrentUser, CurrentUser, appID, "", IntroductoryInformationItem);

                    // Close service communication
                    sc.Close();

                    // Retrieve item returned by service
                    var createdIntroductoryInformation = returnedObject.IntroductoryInformationItem;

                    // Map data contract to model
                    model.IntroductoryInformationItem = Mapper.Map <IntroductoryInformationModel>(createdIntroductoryInformation);

                    //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 = IntroductoryInformationAccessContext.Edit;

                    // Save version of item returned by service into session
                    sessionManager.IntroductoryInformationServiceVersion = model.IntroductoryInformationItem;
                    sessionManager.CurrentIntroductoryInformation        = model.IntroductoryInformationItem;

                    // 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, sc);
                    model.Message = message;

                    return(View(model));
                }
            }

            return(View(model));
        }
Exemplo n.º 5
0
        private static void CreateSubMenu(TagBuilder accordion, string menu, string userName)
        {
            TagBuilder h3;

            h3 = new TagBuilder("h3");

            var a1 = new TagBuilder("a");

            a1.Attributes["href"] = "#";
            a1.InnerHtml          = menu;
            h3.InnerHtml         += a1.ToString();

            TagBuilder h4;
            TagBuilder div;

            var accordionSub = new TagBuilder("div");
            var extraDiv     = new TagBuilder("div");

            accordionSub.GenerateId("accordionSub");

            UcbServiceClient sc = new UcbServiceClient();

            try
            {
                var publishedReportsByCategory = sc.GetPublishedReportsByCategory(userName, userName, "Ucb", "");
                foreach (var category in publishedReportsByCategory)
                {
                    h4 = new TagBuilder("h4");

                    var a = new TagBuilder("a");
                    a.Attributes["href"] = "#";
                    a.InnerHtml          = category.Category;

                    div = new TagBuilder("div");
                    var ul = new TagBuilder("ul");
                    ul.GenerateId("nav");

                    foreach (var li in CreateSubMenuItem(category.StandardReports))
                    {
                        ul.InnerHtml += li.ToString();
                    }


                    div.InnerHtml = ul.ToString();

                    h4.InnerHtml += a.ToString();

                    accordionSub.InnerHtml += h4.ToString();
                    accordionSub.InnerHtml += div.ToString();
                }
            }
            catch (Exception e)
            {
                string message = ExceptionManager.HandleException(e, sc);
            }

            finally
            {
                sc.Close();
            }


            accordion.InnerHtml += h3.ToString();
            extraDiv.InnerHtml  += accordionSub.ToString();
            accordion.InnerHtml += extraDiv.ToString();
        }