Пример #1
0
        public ActionResult Delete(int?taxPK)
        {
            ITaxesRepository taxesRepository = new TaxesRepository(db);

            if (taxPK != null)
            {
                Tax tax = taxesRepository.GetTaxByPK((int)taxPK);

                tax.Deleted = true;

                taxesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("DELETE", tax.TaxPK);
            }

            return(Redirect(Request.UrlReferrer.AbsoluteUri));
        }
Пример #2
0
        public ActionResult Edit(int?taxPK)
        {
            if (taxPK != null)
            {
                ITaxesRepository taxesRepository = new TaxesRepository(db);
                Tax     tax     = taxesRepository.GetTaxByPK((int)taxPK);
                TaxView taxView = new TaxView();

                taxView.ConvertFrom(tax, taxView);

                return(View(taxView));
            }
            else
            {
                return(RedirectToAction("Index", "Tax"));
            }
        }
Пример #3
0
        public ActionResult Edit(TaxView taxModel)
        {
            if (ModelState.IsValid)
            {
                ITaxesRepository taxesRepository = new TaxesRepository(db);
                Tax tax = taxesRepository.GetTaxByPK((int)taxModel.TaxPK);
                taxModel.ConvertTo(taxModel, tax);

                taxesRepository.SaveChanges();

                TempData["message"] = LayoutHelper.GetMessage("UPDATE", tax.TaxPK);

                return(RedirectToAction("Index", "Tax"));
            }
            else
            {
                return(View(taxModel));
            }
        }
Пример #4
0
        public ActionResult LegalEntities(string Name, string OIB, string MB, string MBS, int?BankPK, int?TaxPK, int?FormPK, int?ActivityPK, int?SubstationPK, int?CommercialCourtPK, int?NumberOfEmployeesFrom, int?NumberOfEmployeesTo, int?FundamentalCapitalFrom, int?FundamentalCapitalTo, string TouristOffice, string MonumentAnnuity)
        {
            string sortOrder  = !string.IsNullOrWhiteSpace(Request.QueryString["sortOrder"]) ? Request.QueryString["sortOrder"] : "DESC";
            string sortColumn = !string.IsNullOrWhiteSpace(Request.QueryString["sortColumn"]) ? Request.QueryString["sortColumn"] : "LegalEntityPK";
            string ordering   = sortColumn + " " + sortOrder;

            ordering = ordering.Trim();

            IBanksRepository            banksRepository            = new BanksRepository(db);
            ITaxesRepository            taxesRepository            = new TaxesRepository(db);
            IFormsRepository            formsRepository            = new FormsRepository(db);
            IActivitiesRepository       activitiesRepository       = new ActivitiesRepository(db);
            ISubstationsRepository      substationsRepository      = new SubstationsRepository(db);
            ICommercialCourtsRepository commercialCourtsRepository = new CommercialCourtsRepository(db);

            // Binding DDL for report search
            ViewBag.Banks            = new SelectList(banksRepository.GetValid().OrderBy("Name ASC").ToList(), "BankPK", "Name", BankPK);
            ViewBag.Taxes            = new SelectList(taxesRepository.GetValid().OrderBy("Name ASC").ToList(), "TaxPK", "Name", TaxPK);
            ViewBag.Forms            = new SelectList(formsRepository.GetValid().OrderBy("Name ASC").ToList(), "FormPK", "Name", FormPK);
            ViewBag.Activities       = new SelectList(activitiesRepository.GetValid().OrderBy("Name ASC").ToList(), "ActivityPK", "Name", ActivityPK);
            ViewBag.Substations      = new SelectList(substationsRepository.GetValid().OrderBy("Name ASC").ToList(), "SubstationPK", "Name", SubstationPK);
            ViewBag.CommercialCourts = new SelectList(commercialCourtsRepository.GetValid().OrderBy("Name ASC").ToList(), "CommercialCourtPK", "Name", CommercialCourtPK);

            if (BankPK != null)
            {
                ViewBag.Bank = banksRepository.GetBankByPK((int)BankPK).Name;
            }
            if (TaxPK != null)
            {
                ViewBag.Tax = taxesRepository.GetTaxByPK((int)TaxPK).Name;
            }

            if (SubstationPK != null)
            {
                ViewBag.Substation = substationsRepository.GetSubstationByPK((int)SubstationPK).Name;
            }
            if (CommercialCourtPK != null)
            {
                ViewBag.CommercialCourt = commercialCourtsRepository.GetCommercialCourtByPK((int)CommercialCourtPK).Name;
            }

            if (FormPK != null)
            {
                ViewBag.Form = formsRepository.GetFormByPK((int)FormPK).Name;
            }
            if (ActivityPK != null)
            {
                ViewBag.Activity = activitiesRepository.GetActivityByPK((int)ActivityPK).Name;
            }

            bool?TouristOfficeFlag   = null;
            bool?MonumentAnnuityFlag = null;

            if (TouristOffice == "on")
            {
                TouristOfficeFlag = true;
            }
            if (MonumentAnnuity == "on")
            {
                MonumentAnnuityFlag = true;
            }

            // Applying filters
            IQueryable <LegalEntityView> legalEntities = LegalEntityView.GetLegalEntitiesReport(db, Name, OIB, MB, MBS, BankPK, TaxPK, FormPK, ActivityPK, SubstationPK, CommercialCourtPK, NumberOfEmployeesFrom, NumberOfEmployeesTo, FundamentalCapitalFrom, FundamentalCapitalTo, TouristOfficeFlag, MonumentAnnuityFlag)
                                                         .OrderBy(ordering);

            // Excluding temporary deleted items from view
            legalEntitiesPKsToExclude = new List <int>();

            // Empty session on first request
            if (Request.QueryString.Count == 0)
            {
                Session["legalEntitiesPKsToExclude"] = null;
            }

            if (Session["legalEntitiesPKsToExclude"] != null)
            {
                legalEntitiesPKsToExclude = (List <int>)Session["legalEntitiesPKsToExclude"];
                legalEntities             = legalEntities.Where(c => !legalEntitiesPKsToExclude.Contains(c.LegalEntityPK));
            }

            return(View("LegalEntities", legalEntities.ToList()));
        }