Пример #1
0
        public RegistrationFormViewModel GetRegistrationViewModels(int id)
        {
            RegistrationFormViewModel model = new RegistrationFormViewModel();

            using (var unitOfWork = new UnitOfWork(_dbContext))
            {
                Member member = unitOfWork
                                .Members.Get(id);
                if (member != null)
                {
                    model.Member = member.Adapt <MemberViewModels>();
                }

                SpouseViewModels spouse = unitOfWork
                                          .Spouses
                                          .GetSpouseByMemberId(id)
                                          .Adapt <SpouseViewModels>();

                model.Spouse = (spouse != null)
                    ? spouse
                    : null;

                List <DependentViewModels> dependents = unitOfWork
                                                        .Dependents
                                                        .GetDependentsByMemberId(id)
                                                        .Adapt <List <DependentViewModels> >();
                if (dependents.Count > 0)
                {
                    model.Dependent = dependents;
                }

                PaymentViewModel payment = unitOfWork
                                           .Payments
                                           .GetPaymentByMemberId(id)
                                           .Adapt <PaymentViewModel>();
                if (payment != null)
                {
                    model.Payment = payment;
                    List <ChequeViewModels> cheques = unitOfWork
                                                      .Cheques
                                                      .GetChequesByPaymentId(payment.Id)
                                                      .Adapt <List <ChequeViewModels> >();
                    if (cheques.Count > 0)
                    {
                        model.Payment.Cheques = cheques;
                    }

                    FeeViewModels fee = unitOfWork
                                        .Fees
                                        .Get(payment.MembershipFeeId)
                                        .Adapt <FeeViewModels>();
                }

                model.Member.Locations  = unitOfWork.Locations.GetDropDown(unitOfWork);
                model.Member.Categories = unitOfWork.Categories.GetDropDown(unitOfWork);
                model.Member.Referrers  = unitOfWork.Referrers.GetDropDown(unitOfWork);
                model.Payment.Modes     = unitOfWork.Modes.GetDropDown(unitOfWork);
            }
            return(model);
        }
Пример #2
0
        public IActionResult Add(FeeViewModels model)
        {
            int id = 0;

            if (ModelState.IsValid)
            {
                using (IUnitOfWork unitOfWork = new UnitOfWork(_dbContext))
                {
                    var fee = unitOfWork.Fees.Get(model.Id);
                    if (fee != null)
                    {
                        id = fee.Id;
                        model.Adapt(fee);
                        unitOfWork.Fees.Update(fee);
                        unitOfWork.Commit();
                    }
                    else
                    {
                        var newFee = model.Adapt <Fee>();
                        newFee.Created = User.Identity.Name;
                        unitOfWork.Fees.Add(newFee);
                        id = unitOfWork.Commit();
                    }
                }
            }
            return(RedirectToAction("Details", new { id }));
        }
Пример #3
0
        public FeeViewModels CreateFee(int id)
        {
            var fee = new FeeViewModels();

            using (var unitOfWork = new UnitOfWork(_dbContext))
            {
                var model = unitOfWork.Fees.Get(id);
                if (model != null)
                {
                    fee = model.Adapt <FeeViewModels>();
                }
                fee.Locations = unitOfWork.Locations.GetDropDown(unitOfWork);
            };

            return(fee);
        }