Пример #1
0
        public async Task <ActionResult <Offices> > PostOffices(Offices offices)
        {
            _context.Offices.Add(offices);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetOffices", new { id = offices.Id }, offices));
        }
Пример #2
0
 public frmAddEditOffices(Offices oldValue, MethodType methodType)
 {
     InitializeComponent();
     this.methodType = methodType;
     this.oldValue   = oldValue;
     Details();
 }
Пример #3
0
        public async Task <IActionResult> Edit(uint id, [Bind("Id,Name,OfficeNumber,Budget")] Offices offices)
        {
            if (id != offices.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(offices);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OfficesExists(offices.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(offices));
        }
Пример #4
0
        public List <SelectListItem> GetOfficeList(ILocalizationManager localizationManager)
        {
            var list = new List <SelectListItem>
            {
                new SelectListItem
                {
                    Text     = localizationManager.GetString(CRSConsts.LocalizationSourceName, "PleaseSelect"),
                    Value    = "",
                    Selected = OfficeCode == null
                }
            };
            var officeList = Offices.ToList();

            list.AddRange(officeList
                          .Select(office =>
                                  new SelectListItem
            {
                Text     = office.Name.ToString(),
                Value    = office.Code.ToString(),
                Selected = office.Equals(OfficeCode)
            })
                          );

            return(list);
        }
Пример #5
0
        public ActionResult CreateOfficeProject(Offices office)
        {
            var listProjectType = proType.ListProjectTypes();

            ViewBag.listProjectTypeDll = new SelectList(listProjectType, "Project_type_id", "Project_type_name");

            var listPhaseTypes = phaseType.ListPhaseTypes();

            ViewBag.listPhaseTypesDll = new SelectList(listPhaseTypes, "Phase_id", "Phase_name");

            var listSpeedConnectionsTypes = speedType.ListSpeedConnectionTypes();

            ViewBag.listSpeedConnectionsTypesDll = new SelectList(listSpeedConnectionsTypes, "Speed_connection_id", "Speed_connection_name");

            var listOfficeScopes = offScop.ListOfficeScopes();

            ViewBag.listOfficeScopesDll = new SelectList(listOfficeScopes, "Office_scope_id", "Office_scope_name");

            if (office.Office_requestor_id != null)
            {
                //Changes the lab project null to 2=Laboratory
                office.Project_type = 1;
                try
                {
                    if (!ModelState.IsValid)
                    {
                        return(View());
                    }

                    var officeToAdd = Mapper.Map <DATA.Offices>(office);
                    off.AddOfficeProject(officeToAdd);
                    int x = (Int32)Session["UserType"];
                    switch (x)
                    {
                    case 1:
                        return(RedirectToAction("PmProjects", "User"));

                    case 2:
                        return(RedirectToAction("UserMyProjects", "User"));

                    case 3:
                        return(RedirectToAction("Index", "Office"));

                    case 4:
                        return(RedirectToAction("Index", "Office"));

                    default:
                        return(RedirectToAction("Index", "Home"));
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            else
            {
                return(View());
            }
        }
Пример #6
0
 void Save()
 {
     try
     {
         if (MessageBox.Show("Do you want to submit this?", "Submit", MessageBoxButtons.YesNo,
                             MessageBoxIcon.Question) == DialogResult.No)
         {
             return;
         }
         UnitOfWork unitOfWork = new UnitOfWork();
         offices                          = unitOfWork.OfficesRepo.Find(x => x.Id == offices.Id);
         offices.OffcAcr                  = txtOfficeAcr.Text;
         offices.OfficeName               = txtOfficeName.Text;
         offices.TelNo                    = txtTelNo.Text;
         offices.Address                  = txtAddress.Text;
         offices.Chief                    = txtHeadChief.Text;
         offices.ChiefPosition            = txtPosition.Text;
         offices.ResponsibilityCenter     = txtResponsibilityCenter.Text;
         offices.ResponsibilityCenterCode = txtCode.Text;
         offices.InsideAddress            = txtInsideAddress.ToHtml();
         offices.IsDivision               = chkDivision.Checked;
         offices.UnderOf                  = cboUnderOf.EditValue?.ToInt();
         unitOfWork.Save();
         this.isClosed = true;
         Close();
     }
     catch (Exception ex)
     {
     }
 }
Пример #7
0
        private Control GenerateReport(string stateCode, string countyCode,
                                       string congressionalDistrict, string stateSenateDistrict,
                                       string stateHouseDistrict, bool includeLocals, bool localsSeparated = false)
        {
            ReportUser = ReportUser.Public;

            DataManager.SetData(Offices.GetElectedReportData(stateCode, countyCode,
                                                             congressionalDistrict, stateSenateDistrict, stateHouseDistrict, includeLocals));

            (new USPresidentCategory()).Generate(this);
            (new USSenateCategory()).Generate(this, false, stateCode);
            (new USHouseCategory()).Generate(this, false, stateCode);
            (new USGovernorsCategory()).Generate(this, false, stateCode);
            (new StatewideCategory()).Generate(this, false, stateCode);
            (new StateSenateCategory()).Generate(this, false, stateCode);
            (new StateHouseCategory()).Generate(this, false, stateCode);
            (new CountyCategory()).Generate(this, false, stateCode, countyCode);
            if (includeLocals)
            {
                var reportContainer = ReportContainer;
                if (localsSeparated)
                {
                    new HtmlDiv {
                        InnerText = "Local Elected Officials"
                    }.AddTo(ReportContainer, "category-title accordion-header elected-report-locals");
                    reportContainer = new HtmlDiv().AddTo(ReportContainer,
                                                          "category-content accordion-content elected-report-locals elected-report-locals-content");
                }
                new AllLocalsCategory().GenerateAll(this, stateCode, countyCode, reportContainer);
            }

            return(ReportContainer.AddCssClasses("elected-report"));
        }
Пример #8
0
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable MemberCanBeProtected.Global
        // ReSharper disable UnusedMember.Global
        // ReSharper disable UnusedMethodReturnValue.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        // ReSharper disable UnassignedField.Global

        #endregion ReSharper disable

        public static void GetReport(Control container, string stateCode)
        {
            // We get a dictionary of office counts by county
            // Key: countyCode; Value: count of offices
            // Counties with no offices will not be in the dictionary
            var countCountyOfficesDictionary =
                Offices.CountCountyOfficesByCounty(stateCode);

            if (countCountyOfficesDictionary.Count == 0)
            {
                return;
            }

            new HtmlDiv {
                InnerText = "County Elected Representatives"
            }.AddTo(container, "accordion-header");
            var content = new HtmlDiv().AddTo(container, "local-anchors accordion-content");

            // For reporting we start with all counties for the state (it will be in
            // order by county name). Then we select only those in the offices dictionary.
            var reorderedCounties = CountyCache.GetCountiesByState(stateCode)
                                    .Where(countCountyOfficesDictionary.ContainsKey)
                                    .ToList();

            foreach (var iteratedCountyCode in reorderedCounties)
            {
                var countyName = CountyCache.GetCountyName(stateCode, iteratedCountyCode);
                CreatePublicOfficalsAnchor(countyName, stateCode, iteratedCountyCode)
                .AddTo(content, "local-anchor");
            }
        }
Пример #9
0
        public async Task <IActionResult> Create([Bind("OfficeId,OfficeName,OfficeNotes,OfficeHousesId,OfficeIsStore")] Offices offices,
                                                 bool OfficeIsStore,
                                                 string filter = "", int page = 1, string sortExpression = "OfficeId")
        {
            ViewBag.Filter         = filter;
            ViewBag.Page           = page;
            ViewBag.SortExpression = sortExpression;

            offices.OfficeIsStore = OfficeIsStore ? 1 : 0;

            ModelState.Clear();
            if (ModelState.IsValid)
            {
                _context.Add(offices);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index),
                                        new
                {
                    filter = filter,
                    page = page,
                    sortExpression = sortExpression
                }));
            }

            ViewData["OfficeRegionId"] = new SelectList(_context.Region, "RegionId", "RegionName");
            ViewData["OfficeHousesId"] = new SelectList(_context.Houses, "HouseId", "HouseName");

            return(View(offices));
        }
Пример #10
0
        private void CreateOfficeTitle(Control categoryContent, Control officeContent,
                                       IList <DataRow> politicians, string officeTitle)
        {
            var officeHeading = officeTitle;
            var officeInfo    = politicians[0];

            switch (officeInfo.ElectionType())
            {
            case Elections.ElectionTypeUSPresidentialPrimary:
            case Elections.ElectionTypeStatePresidentialPrimary:
            case Elections.ElectionTypeStatePrimary:
                officeHeading += " " +
                                 Parties.GetNationalPartyDescription(officeInfo.NationalPartyCode());
                break;
            }

            var titleDiv = new HtmlDiv().AddTo(categoryContent, "office-title accordion-header");

            new HtmlSpan {
                InnerText = officeHeading
            }.AddTo(titleDiv);
            new HtmlSpan
            {
                //InnerText = $" {Offices.GetVoteForNoMoreThanWording(officeInfo.ElectionPositions())}"
                InnerText = $" {Offices.GetVoteForNoMoreThanWording(GetElectionPositions(officeInfo))}"
            }.AddTo(titleDiv, "vote-for");

            CreateMasterOfficeLinks(officeContent, officeInfo, politicians.Count(p => p.IsWinner()));
        }
Пример #11
0
        // ReSharper disable MemberCanBePrivate.Global
        // ReSharper disable MemberCanBeProtected.Global
        // ReSharper disable UnusedMember.Global
        // ReSharper disable UnusedMethodReturnValue.Global
        // ReSharper disable UnusedAutoPropertyAccessor.Global
        // ReSharper disable UnassignedField.Global

        #endregion ReSharper disable

        public static void GetReport(Control container, string stateCode, string countyCode)
        {
            // Get a dictionary of all locals with offices defined
            // Key: localCode; Value: localDistrictName
            var localNamesWithOfficesDictionary =
                Offices.GetLocalNamesWithOffices(stateCode, countyCode);

            if (localNamesWithOfficesDictionary.Count == 0)
            {
                return;
            }

            // For reporting, we sort the dictionary by name
            var sortedListOflocalNamesWithOffices = localNamesWithOfficesDictionary
                                                    .OrderBy(kvp => kvp.Value)
                                                    .Select(kvp => kvp.Key)
                                                    .ToList();

            new HtmlDiv {
                InnerText = "Local District Elected Representatives"
            }.AddTo(container,
                    "accordion-header");
            var content = new HtmlDiv().AddTo(container, "local-anchors accordion-content");

            foreach (var iteratedLocalCode in sortedListOflocalNamesWithOffices)
            {
                var localName = localNamesWithOfficesDictionary[iteratedLocalCode];
                CreatePublicOfficalsAnchor(localName, stateCode, countyCode, iteratedLocalCode)
                .AddTo(content, "local-anchor");
            }
        }
Пример #12
0
        //private int PopulateWinnersTreeOld(DataTable table, Control parent,
        //  bool isPrimary)
        //{
        //  var officeCount = 0;
        //  parent.Controls.Clear();
        //  var tree = new HtmlUl().AddTo(parent);

        //  var rootText = isPrimary
        //    ? "Cannot update incumbents for primary election"
        //    : "Check to update incumbents in addition to recording winners";

        //  var rootData = isPrimary
        //    ? "addClass:'root-node no-checkbox',hideCheckbox:true,unselectable:true"
        //    : "addClass:'root-node'";

        //  var rootNode =
        //    new HtmlLi
        //    {
        //      InnerHtml = rootText
        //    }.AddTo(tree);
        //  rootNode.Attributes.Add("data", rootData);
        //  var rootTree = new HtmlUl().AddTo(rootNode);

        //  var officeClasses = table.Rows.Cast<DataRow>()
        //    .GroupBy(row => row.OfficeClass());
        //  foreach (var officeClass in officeClasses)
        //  {
        //    var offices = officeClass.GroupBy(row => row.OfficeKey())
        //      .ToList();
        //    officeCount += offices.Count;
        //    if (offices.Count == 1)
        //      PopulateWinnersTree_CreateNodeOld(rootTree, offices[0], false, false);
        //    else
        //    {
        //      // If all OfficeLine1's are identical, don't show them
        //      var hasVariedLine1 = offices.Exists(row => row.First()
        //        .OfficeLine1() != offices[0].First()
        //          .OfficeLine1());
        //      var text = Offices.GetOfficeClassShortDescription(officeClass.Key,
        //        StateCode);
        //      var classNode =
        //        new HtmlLi { InnerHtml = text }.AddTo(rootTree);
        //      classNode.Attributes.Add("data",
        //        "addClass:'office-class office-class-" + officeClass.Key +
        //         "',key:'office-class-" + officeClass.Key + "'");
        //      var classSubTree = new HtmlUl().AddTo(classNode);
        //      foreach (var office in offices)
        //        PopulateWinnersTree_CreateNodeOld(classSubTree, office, !hasVariedLine1, isPrimary);
        //    }
        //  }
        //  return officeCount;
        //}

        //private void PopulateWinnersTree_CreateNodeOld(Control parent,
        //  IEnumerable<DataRow> office, bool useLine2Only = false,
        //  bool isPrimary = false)
        //{
        //  var officeRows = office.ToList();
        //  var officeInfo = officeRows[0];
        //  var officeState = Offices.GetStateCodeFromKey(officeInfo.OfficeKey());
        //  var electionState = Elections.GetStateCodeFromKey(GetElectionKey());
        //  var canUpdateIncumbents = StateCache.IsValidStateCode(officeState) &&
        //    StateCache.IsValidStateCode(electionState) && !isPrimary;

        //  var winners = officeRows.Where(row => row.IsWinner())
        //    .ToList();
        //  var candidates = officeRows.Where(row => !row.IsIncumbentRow())
        //    .ToList();
        //  var incumbents = officeRows.Where(row => row.IsIncumbentRow())
        //    .ToList();

        //  // We begin by creating a dropdown for each already-identified winner,
        //  // with the default selection as the winner.
        //  var dropdownContents =
        //    winners.Select(
        //      winner =>
        //        new
        //        {
        //          DefaultPolitician = winner.PoliticianKey(),
        //          List = new List<DataRow>(candidates)
        //        })
        //      .ToList();

        //  if (dropdownContents.Count < officeInfo.Incumbents())
        //    // We need additional dropdowns
        //    // If this is a single incumbent office, we add incumbent as
        //    // default selection only if a candidate
        //    if (officeInfo.Incumbents() == 1)
        //      dropdownContents.AddRange(incumbents.Where(
        //        incumbent =>
        //          candidates.FirstOrDefault(candidate => candidate.PoliticianKey()
        //            .IsEqIgnoreCase(incumbent.PoliticianKey())) != null)
        //        .Select(
        //          incumbent =>
        //            new
        //            {
        //              DefaultPolitician = incumbent.PoliticianKey(),
        //              List = new List<DataRow>(candidates)
        //            }));
        //    else
        //      // There are multiple incumbent slots
        //      if (winners.Count > 0)
        //        // There were winners, but not enough to fill all slots.
        //        // We add any incumbents NOT in the election as defaults, along
        //        // with all candidates
        //        dropdownContents.AddRange(incumbents.Where(
        //          incumbent =>
        //            candidates.FirstOrDefault(candidate => candidate.PoliticianKey()
        //              .IsEqIgnoreCase(incumbent.PoliticianKey())) == null)
        //          .Select(
        //            incumbent =>
        //              new
        //              {
        //                DefaultPolitician = incumbent.PoliticianKey(),
        //                List =
        //                  new List<DataRow>(
        //                    candidates.Union(new List<DataRow> { incumbent }))
        //              }));
        //      else
        //        // No winners were identified. Add all incumbents as defaults,
        //        // whether in the election or not. The Where on candidates is to
        //        // prevent a duplicate entry when the incumbent is in the election
        //        dropdownContents.AddRange(
        //          incumbents.Select(
        //            incumbent =>
        //              new
        //              {
        //                DefaultPolitician = incumbent.PoliticianKey(),
        //                List =
        //                  new List<DataRow>(candidates.Where(
        //                    candidate => candidate.PoliticianKey()
        //                      .IsNeIgnoreCase(incumbent.PoliticianKey()))
        //                    .Union(new List<DataRow> { incumbent }))
        //              }));

        //  // If there are still office slots to fill, fill them out with undefaulted
        //  // candidate lists.
        //  while (dropdownContents.Count < officeInfo.Incumbents())
        //    dropdownContents.Add(
        //      new
        //      {
        //        DefaultPolitician = String.Empty,
        //        List = new List<DataRow>(candidates)
        //      });

        //  // Now create the node
        //  // Format he office description
        //  var text = useLine2Only
        //    ? officeInfo.OfficeLine2()
        //    : Offices.FormatOfficeName(officeInfo);
        //  // Include the incumbent slot count if > 1
        //  if (officeInfo.Incumbents() > 1)
        //    text = String.Format("{0} [{1}]", text, officeInfo.Incumbents());

        //  var data = "key:'" + officeInfo.OfficeKey();
        //  if (canUpdateIncumbents)
        //    data += "',addClass:'office-name'";
        //  else
        //    data +=
        //      "',addClass:'office-name no-checkbox',hideCheckbox:true,unselectable:true";
        //  var officeNode = new HtmlLi().AddTo(parent);
        //  officeNode.Attributes.Add("data", data);
        //  new HtmlDiv { InnerHtml = text }.AddTo(officeNode, "label");
        //  var dropdownDiv = new HtmlDiv().AddTo(officeNode,
        //    "dropdowns idwinners-" + officeInfo.OfficeKey());

        //  // Create the dropdowns
        //  foreach (var dropdownContent in dropdownContents)
        //  {
        //    var dropdownList =
        //      new HtmlSelect { EnableViewState = false }.AddTo(dropdownDiv);

        //    // The first option in each dropdown is a disabled header
        //    var dropDownMessage = officeInfo.Incumbents() == 1
        //      ? "Select winner or Vacant"
        //      : "Select winner, incumbent or Vacant";
        //    var option = dropdownList.AddItem(dropDownMessage, String.Empty,
        //      dropdownContent.DefaultPolitician == String.Empty);
        //    option.Attributes.Add("disabled", "disabled");

        //    // Add an option for each politician
        //    foreach (
        //      var politician in dropdownContent.List.OrderBy(row => row.LastName())
        //        .ThenBy(row => row.FirstName()))
        //    {
        //      var name = Politicians.FormatName(politician);
        //      if (!String.IsNullOrWhiteSpace(politician.PartyCode()))
        //        name += " (" + politician.PartyCode() + ")";
        //      var indicators = String.Empty;

        //      // Add winner indicator
        //      if (winners.FirstOrDefault(winner => winner.PoliticianKey()
        //        .IsEqIgnoreCase(politician.PoliticianKey())) != null)
        //        indicators += "◄";

        //      // Add incumbent indicator
        //      if (incumbents.FirstOrDefault(incumbent => incumbent.PoliticianKey()
        //        .IsEqIgnoreCase(politician.PoliticianKey())) != null)
        //        if (candidates.FirstOrDefault(candidate => candidate.PoliticianKey()
        //          .IsEqIgnoreCase(politician.PoliticianKey())) != null)
        //          indicators += "■";
        //        else
        //          indicators += "□";

        //      if (indicators != String.Empty)
        //        name += " " + indicators;

        //      dropdownList.AddItem(name, politician.PoliticianKey(),
        //        dropdownContent.DefaultPolitician == politician.PoliticianKey());
        //    }

        //    // Add a "Vacant" option
        //    dropdownList.AddItem("Vacant", "vacant");
        //  }
        //}

        private int PopulateWinnersTree(DataTable table, Control parent)
        {
            var officeCount = 0;

            parent.Controls.Clear();
            var tree = new HtmlUl().AddTo(parent);

            const string rootText = "Check to update incumbents in addition to recording winners";

            const string rootData = "addClass:'root-node'";

            var rootNode =
                new HtmlLi
            {
                InnerHtml = rootText
            }.AddTo(tree);

            rootNode.Attributes.Add("data", rootData);
            var rootTree = new HtmlUl().AddTo(rootNode);

            var officeClasses = table.Rows.Cast <DataRow>()
                                .GroupBy(row => row.OfficeClass());
            var even = false;

            foreach (var officeClass in officeClasses)
            {
                var offices = officeClass.GroupBy(row => row.OfficeKey())
                              .ToList();
                officeCount += offices.Count;
                if (offices.Count == 1)
                {
                    PopulateWinnersTree_CreateNode(rootTree, offices[0], /*even ? "even" :*/ "odd");
                    even = !even;
                }
                else
                {
                    // If all OfficeLine1's are identical, don't show them
                    var hasVariedLine1 = offices.Exists(row => row.First()
                                                        .OfficeLine1() != offices[0].First()
                                                        .OfficeLine1());
                    var text = Offices.GetOfficeClassShortDescription(officeClass.Key,
                                                                      StateCode);
                    var classNode =
                        new HtmlLi {
                        InnerHtml = text
                    }.AddTo(rootTree);
                    classNode.Attributes.Add("data",
                                             "addClass:'office-class office-class-" + officeClass.Key +
                                             "',key:'office-class-" + officeClass.Key + "'");
                    var classSubTree = new HtmlUl().AddTo(classNode);
                    foreach (var office in offices)
                    {
                        PopulateWinnersTree_CreateNode(classSubTree, office, /*even ? "even" :*/ "odd",
                                                       !hasVariedLine1);
                    }
                    even = !even;
                }
            }
            return(officeCount);
        }
Пример #13
0
            public override void LoadControl()
            {
                OfficeCount = 0;
                var table = Elections.GetWinnersData(Page.GetElectionKey());
                var incumbentsToEliminate =
                    ElectionsOffices.GetOfficesWithCandidatesToEliminate(Page.GetElectionKey());

                if (table.Rows.Count == 0)
                {
                    Page.IdentifyWinnersMessage.RemoveCssClass("hidden");
                    Page.IdentifyWinnersInstructions.RemoveCssClass("hidden");
                    Page.IdentifyWinnersControl.AddCssClasses("hidden");
                    Page.IdentifyWinnersMessage.InnerHtml = "No offices were found for this election";
                }
                else if (incumbentsToEliminate.Count > 0)
                {
                    Page.IdentifyWinnersMessage.RemoveCssClass("hidden");
                    Page.IdentifyWinnersInstructions.AddCssClasses("hidden");
                    Page.IdentifyWinnersControl.AddCssClasses("hidden");
                    Page.IdentifyWinnersMessage.InnerHtml =
                        "<em>There are too many incumbents for the following offices:</em><br/><br/>" +
                        Join("<br/>",
                             incumbentsToEliminate.Select(g => Offices.FormatOfficeName(g.First()))) +
                        "<br/><br/><em>Please use the </em>Adjust Incumbents<em> tab to remove the extra incumbents or use the </em>Add/Remove Offices<em> tab to remove the office contest.</em>";
                }
                else
                {
                    Page.IdentifyWinnersMessage.AddCssClasses("hidden");
                    Page.IdentifyWinnersInstructions.RemoveCssClass("hidden");
                    Page.IdentifyWinnersControl.RemoveCssClass("hidden");
                    OfficeCount =
                        Page.PopulateWinnersTree(table, Page.PlaceHolderIdentifyWinnersTree);
                }
            }
Пример #14
0
        private void UpdateLockedClasses()
        {
            // Get all OfficesAllIdentified rows for the state and make a dictionary of
            // only the true values
            var dictionary = OfficesAllIdentified.GetDataByStateCode(StateCode)
                             .Where(row => row.IsOfficesAllIdentified)
                             .ToDictionary(row => row.OfficeLevel.ToOfficeClass(),
                                           row => null as object);

            // now get any items that don't match the dictionary
            var items = ControlMasterOnlyClassesToLock.Items.OfType <ListItem>()
                        .Where(
                item =>
                dictionary.ContainsKey(Offices.GetValidatedOfficeClass(item.Value)) !=
                item.Selected);

            foreach (var item in items)
            {
                var officeClass = Offices.GetValidatedOfficeClass(item.Value);
                OfficesAllIdentified.UpdateIsOfficesAllIdentified(item.Selected, StateCode,
                                                                  officeClass.ToInt());
            }

            FeedbackMasterOnly.AddInfo("The locked office classes were updated");
        }
Пример #15
0
        public MFCBotModel(MFCBotContext dbContext)
        {
            SectionOffices = dbContext.SectionOffice.ToList();

            Offices = dbContext.Office.Where(x => (x.IsActive != null && x.TerritoryID != null && (bool)x.IsActive) || x.Name == "Ярмарка").ToList();

            var supportedOffices = SectionOffices.Select(y => y.OfficeID);

            Offices = Offices.Where(x => supportedOffices.Contains(x.OfficeID)).ToList();

            //Services = dbContext.Service.DistinctBy(x => x.DisplayName).OrderByDescending(x => x.Priority).ToList(); // исключил услуги за ненадобностью. Оставил в коде на всякий случай
            //foreach (var item in Services)
            //{
            //    item.DisplayName = item.DisplayName.Replace("\r", "");
            //    item.DisplayName = item.DisplayName.Replace("\n", "");
            //    item.DisplayName = item.DisplayName.Replace(Environment.NewLine, "");
            //}

            AllSections = dbContext.Section.Where(x => x.IsActive).OrderByDescending(x => x.Rating).ToList();
            foreach (var item in Sections)
            {
                item.Name = item.Name.Replace("\r", "");
                item.Name = item.Name.Replace("\n", "");
                item.Name = item.Name.Replace(Environment.NewLine, "");
            }

            Texts = dbContext.BotText.ToList();
            Jokes = dbContext.BotJoke.ToList();

            WindowsOffices = dbContext.WindowsOffice.ToList();
        }
Пример #16
0
        protected void CheckBoxListOfficeClassAllIdentified_SelectedIndexChanged(
            object sender, EventArgs e)
        {
            try
            {
                // Get all OfficesAllIdentified rows for the jurisdiction and make a
                // dictionary of only the true values
                var dictionary = OfficesAllIdentified.GetDataByStateCode(StateCode,
                                                                         CountyCode, LocalCode)
                                 .Where(row => row.IsOfficesAllIdentified)
                                 .ToDictionary(row => row.OfficeLevel.ToOfficeClass(),
                                               row => null as object);

                // now get any items that don't match the dictionary
                var items = CheckBoxListOfficeClassAllIdentified.Items.OfType <ListItem>()
                            .Where(
                    item =>
                    dictionary.ContainsKey(Offices.GetValidatedOfficeClass(item.Value)) !=
                    item.Selected);

                // should only be one item, but we'll loop just in case...
                Msg.Text = string.Empty;
                var regenerateReport = GetSelectedOfficeClass() == OfficeClass.All;
                foreach (var item in items)
                {
                    var officeClass = Offices.GetValidatedOfficeClass(item.Value);
                    if (OfficesAllIdentified.StateCodeOfficeLevelCountyCodeLocalCodeExists(
                            StateCode, officeClass.ToInt(), CountyCode, LocalCode))
                    {
                        OfficesAllIdentified.UpdateIsOfficesAllIdentified(item.Selected,
                                                                          StateCode, officeClass.ToInt(), CountyCode, LocalCode);
                    }
                    else if (item.Selected)
                    {
                        OfficesAllIdentified.Insert(StateCode, CountyCode, LocalCode,
                                                    officeClass.ToInt(), true);
                    }
                    var officeDesc = GetOfficeClassDescription(officeClass, true);
                    Msg.Text += item.Selected
            ? Ok(officeDesc +
                 " was changed to PROHIBIT the addition of offices.")
            : Ok(officeDesc + " was changed to ALLOW the addition of offices.");
                    if (officeClass == GetSelectedOfficeClass())
                    {
                        regenerateReport = true;
                    }
                }
                if (regenerateReport)
                {
                    GenerateReport();
                    UpdatePanel.Update();
                }
            }
            catch (Exception ex)
            {
                Msg.Text = Fail(ex.Message);
                LogException("CheckBoxListOfficeClassAllIdentified_SelectedIndexChanged",
                             ex);
            }
        }
Пример #17
0
 public frmAddEditOffice(Offices offices, MethodType methodType)
 {
     InitializeComponent();
     this.methodType = methodType;
     this.offices    = offices;
     Init();
 }
Пример #18
0
 private string GetOfficeClassDescription(OfficeClass officeClass, bool shortDesc = false)
 =>
 (shortDesc
 ? Offices.GetShortLocalizedOfficeClassDescription(officeClass, StateCode, CountyCode,
                                                   LocalKey)
 : Offices.GetLocalizedOfficeClassDescription(officeClass, StateCode, CountyCode, LocalKey)) +
 " Politicians";
Пример #19
0
        public static string FindLocalKey()
        {
            var stateCode = FindStateCode();

            if (IsNullOrWhiteSpace(stateCode))
            {
                return(Empty);
            }

            var localKey = QueryLocal;

            if (IsNullOrWhiteSpace(localKey))
            {
                if (IsMasterUser || IsAdminUser)
                {
                    localKey = UserLocalKey;
                    if (IsNullOrWhiteSpace(localKey))
                    {
                        localKey = Elections.GetLocalKeyFromKey(QueryElection);
                    }
                    if (IsNullOrWhiteSpace(localKey))
                    {
                        localKey = Offices.GetLocalKeyFromKey(QueryOffice);
                    }
                }
            }
            return(!IsNullOrWhiteSpace(localKey) &&
                   LocalDistricts.IsValidKey(stateCode, localKey)
        ? localKey
        : Empty);
        }
Пример #20
0
        private void LoadLocalLinks()
        {
            var stateCode  = ViewState["StateCode"].ToString();
            var countyCode = ViewState["CountyCode"].ToString();

            TableLocalLinks.Visible = true;
            Label_County.Text       =
                Offices.GetElectoralClassDescription(stateCode, countyCode) +
                " LOCAL DISTRICTS, TOWNS and CITIES (" + countyCode + ")";
            LabelLocalDistricts.Text =
                LocalLinks.GetDefaultLocalLinks(stateCode, countyCode, true, true).RenderToString();
            if (string.IsNullOrEmpty(LabelLocalDistricts.Text))
            {
                LabelLocalDistricts.Text =
                    "No Local Districts, Towns or Cities have been identified for " +
                    Offices.GetElectoralClassDescription(stateCode, countyCode);

                LabelLocalDesc.Text = string.Empty;
            }
            else
            {
                LabelLocalDesc.Text =
                    "Use the links above to EDIT information for any of these local districts," +
                    " towns or cities in this county." +
                    " Use the link below to ADD local districts, towns and cities to this county.";
            }
        }
Пример #21
0
        public async Task <IActionResult> Edit(int id, [Bind("OfficeId,OfficeName,OfficeAddress1,OfficeAddress2,OfficeCity,OfficeState,CountryId,OfficePostalCode,OfficePhoneNumber,OfficeFaxNumber")] Offices offices)
        {
            if (id != offices.OfficeId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(offices);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!OfficesExists(offices.OfficeId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["CountryId"] = new SelectList(_context.Countries, "CountryId", "CountryName", offices.CountryId);

            ViewBag.returnUrl = Request.Headers["Referer"].ToString();
            return(View(offices));
        }
Пример #22
0
        public static ElectoralClass Electoral_Class_Election(string electionKey)
        {
            switch (electionKey.Length)
            {
            case Elections.ElectionKeyLengthStateOrFederal:
                return(Electoral_Class(
                           Offices.GetStateCodeFromKey(electionKey)
                           , string.Empty
                           , string.Empty
                           ));

            case Elections.ElectionKeyLengthCounty:
                return(Electoral_Class(
                           Offices.GetStateCodeFromKey(electionKey)
                           , Elections.GetCountyCodeFromKey(electionKey)
                           , string.Empty
                           ));

            case Elections.ElectionKeyLengthLocal:
                return(Electoral_Class(
                           Offices.GetStateCodeFromKey(electionKey)
                           , Elections.GetCountyCodeFromKey(electionKey)
                           , Elections.GetLocalCodeFromKey(electionKey)
                           ));

            default:
                return(Electoral_Class(
                           string.Empty
                           , string.Empty
                           , string.Empty
                           ));
            }
        }
Пример #23
0
        public ActionResult EditOfficeProject(Offices office)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View());
                }
                var updateOfficeProject = Mapper.Map <DATA.Offices>(office);
                off.UpdateOfficeProject(updateOfficeProject);
                int x = (Int32)Session["UserType"];
                switch (x)
                {
                case 1:
                    return(RedirectToAction("PmProjects", "User"));

                case 2:
                    return(RedirectToAction("UserMyProjects", "User"));

                case 3:
                    return(RedirectToAction("Index", "Office"));

                case 4:
                    return(RedirectToAction("Index", "Office"));

                default:
                    return(RedirectToAction("Index", "Home"));
                }
            }
            catch
            {
                return(View());
            }
        }
Пример #24
0
        private void HandleCompareCandidatesPage()
        {
            var officeKey = string.Empty;

            var electionKey = MemCache.IsValidElection(GetQueryParm("Election"))
        ? GetQueryParm("Election")
        : FixElectionKeyFromQueryString();

            if (!string.IsNullOrEmpty(electionKey))
            {
                if (Offices.IsInElection(GetQueryParm("Office"), electionKey))
                {
                    officeKey = GetQueryParm("Office");
                }
            }

            var stateCode = Elections.GetStateCodeFromKey(electionKey);

            if (!string.IsNullOrEmpty(electionKey) && !string.IsNullOrEmpty(officeKey))
            {
                NormalizedUri = UrlManager.GetCompareCandidatesPageUri(stateCode, electionKey,
                                                                       officeKey);
            }
            else
            {
                ErrorMessage =
                    "Cannot find this combination of State, Election and Office";
            }
        }
Пример #25
0
        private void BindBranchDropDownList()
        {
            Collection <Office> offices = Offices.GetOffices();

            this.BranchDropDownList.DataSource = offices;
            this.BranchDropDownList.DataBind();
        }
 private void BindData()
 {
     drpQuarterCat.DataSource = Quarters.GetQuarterCategory();
     drpQuarterCat.DataBind();
     drpOffice.DataSource = Offices.GetAlloffices();
     drpOffice.DataBind();
 }
Пример #27
0
        private void BindBranchDropDownList()
        {
            IEnumerable <DbGetOfficesResult> offices = Offices.GetOffices(AppUsers.GetCurrentUserDB());

            this.branchSelect.DataSource = offices;
            this.branchSelect.DataBind();
        }
Пример #28
0
        private void button1_Click(object sender, EventArgs e)
        {
            Offices oficinas = new Offices();

            using (oficinas)
            {
                oficinas.Name       = txtNombre.Text;
                oficinas.Domicilio  = txtDomicilio.Text;
                oficinas.Telefono   = txtTelefono.Text;
                oficinas.Servidor   = txtServidor.Text;
                oficinas.Connection = txtCone.Text;
                oficinas.Notas      = txtNotas.Text;
                oficinas.Factura    = txtFacturacion.Text;
                oficinas.Rfc        = txtRfc.Text;
                oficinas.Interior   = txtInterior.Text;
                oficinas.Exterior   = txtExterior.Text;
                oficinas.Calle      = txtCalle.Text;
                oficinas.Colonia    = txtColonia.Text;
                oficinas.Cp         = txtCp.Text;
                oficinas.Municipio  = txtMunicipio.Text;
                oficinas.Estado     = txtEstado.Text;
                if (id != 0)
                {
                    oficinas.Id = id;
                    oficinas.SaveOffice();
                }
                else
                {
                    oficinas.CreateOffice();
                }
            }

            this.Close();
        }
        public IActionResult AddOffice([FromBody] OfficeObj OfficeData)
        {
            try
            {
                UserProfile UP = this.help.GetProfileId(HttpContext, db);
                if (UP.UserId <= 0)
                {
                    return(StatusCode(401, "الرجاء الـتأكد من أنك قمت بتسجيل الدخول"));
                }
                if (UP.ProfileId <= 0)
                {
                    return(StatusCode(401, "الرجاء تفعيل ضبط الملف الانتخابي التشغيلي"));
                }


                Offices offices = new Offices();
                offices.ArabicName  = OfficeData.ArabicName;
                offices.EnglishName = OfficeData.EnglishName;
                offices.Description = OfficeData.Description;
                offices.ProfileId   = UP.ProfileId;
                offices.CreatedBy   = UP.UserId;
                offices.Status      = 1;
                offices.CreatedOn   = DateTime.Now;
                db.Offices.Add(offices);
                db.SaveChanges();

                return(Ok(" تم اضافة المكتب  بنـجاح"));
            }
            catch (Exception e)
            {
                return(StatusCode(500, e.Message));
            }
        }
Пример #30
0
        public async Task <IActionResult> PutOffices(long id, Offices offices)
        {
            if (id != offices.Id)
            {
                return(BadRequest());
            }

            _context.Entry(offices).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!OfficesExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }