Пример #1
0
 public ActionResult AdminPanel()
 {
     if (IsAdmin)
     {
         var model = new FullInfoViewModel()
         {
             Lakes = db.Lakes.ToList(), Boats = db.Boats.ToList(), Fishes = db.Fishes.ToList(), Baits = db.Baits.ToList(), Rods = db.FishRods.ToList(), Hooks = db.Hookses.ToList()
         };
         return(View(model));
     }
     else
     {
         return(RedirectToAction("Index"));
     }
 }
Пример #2
0
        /// <summary>
        /// Action of <see cref="PersonController" />.
        /// <list type="destination"><item><term>Creates a special view model <see cref="FullInfoViewModel" /></term></item><item><term>Redirects to <see cref="Person" /> full information page with created view model.</term></item></list>
        /// </summary>
        /// <param name="currPerson">Requested Person, about whom to show full information.
        /// Creating automatically, by model binding mechanism, using relevant fields of <see cref="Person" />.</param>
        /// <param name="fullName">Full name of clicked Person</param>
        /// <returns>Returns a view with the name of "<c>Views/Person/PersonFull info.cshtml</c>", filled with <see cref="FullInfoViewModel" /> data.</returns>
        public ViewResult PersonFullInfo(Person currPerson, string fullName)
        {
            Address        currAddress        = _repository.AddressRepository.AddressList.First(a => a.Id == currPerson.AddressId);
            Agreement      currAgreement      = _repository.AgreementRepository.AgreementList.First(a => a.PersonId == currPerson.Id);
            FinancialState currFinancialState = _repository.FinancialStateRepository.FinancialStateList.First(f => f.Id == currAgreement.FinancialStateId);

            FullInfoViewModel viewModel = new FullInfoViewModel
            {
                PersonParamValues = new List <string>
                {
                    currPerson.FirstName,
                    currPerson.Surname,
                    currAgreement.Number,
                    currPerson.NationalIdentificationNumber,
                    currPerson.PhoneNumber,
                    currPerson.PhoneNumber2,
                    CreateFullAddress(currAddress.PostOfficeCity,
                                      currAddress.StreetName,
                                      currAddress.StreetNumber,
                                      currAddress.FlatNumber,
                                      currAddress.PostCode),

                    CreateFullAddress(currAddress.CorrespondencePostOfficeCity,
                                      currAddress.CorrespondenceStreetName,
                                      currAddress.CorrespondenceStreetNumber,
                                      currAddress.CorrespondenceFlatNumber,
                                      currAddress.CorrespondencePostCode)
                },
                FinancialStateParamValues = new List <string>
                {
                    currFinancialState.OutstandingLiabilities.ToString(),
                              currFinancialState.Interests.ToString(),
                              currFinancialState.PenaltyInterests.ToString(),
                              currFinancialState.Fees.ToString(),
                              currFinancialState.CourtFees.ToString(),
                              currFinancialState.RepresentationCourtFees.ToString(),
                              currFinancialState.VindicationCosts.ToString(),
                              currFinancialState.RepresentationVindicationCosts.ToString()
                }
            };

            return(View(viewModel));
        }