Пример #1
0
        public ActionResult CreateCardReq(CardReqViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("CreditCard", viewModel));
            }

            var userId     = User.Identity.GetUserId();
            var individual = context.Individuals.SingleOrDefault(i => i.Id == userId);

            var creditCardReq = new CardRequest(individual, RequestType.CardActivation, viewModel.CreditLimit.Value,
                                                viewModel.TransactionAmountLimit.Value, CardType.CreditCard);

            context.CardRequests.Add(creditCardReq);
            context.SaveChanges();

            var hubModel = new { Name = individual.FullName, Type = CardType.CreditCard.ToString() };

            SignalHub.GetRequest(hubModel);

            return(RedirectToAction("Index", "Individuals"));
        }
Пример #2
0
        public ActionResult Save(IndividualFormViewModel ifvm)
        {
            var userId  = User.Identity.GetUserId();
            var appUser = unitOfWork.Users.GetUser(userId);

            if (!ModelState.IsValid)
            {
                var viewModel = new IndividualFormViewModel()
                {
                    Individual     = ifvm.Individual,
                    Phones         = ifvm.Phones,
                    PrimaryAddress = ifvm.PrimaryAddress
                };
                return(View("IndividualForm", viewModel));
            }
            Collection <Phone> viewPhones = new Collection <Phone>(ifvm.Phones);

            if (ifvm.IndividualId == null)
            {
                var individual = Individual.New(ifvm, appUser, viewPhones);
                appUser.RegisterCompletion = true;
                unitOfWork.Individuals.AddIndividual(individual); //2
                var request = new Request(individual, RequestType.UserAccActivation);
                unitOfWork.Requests.AddRequest(request);          //3

                var hubModel = new { Name = ifvm.Individual.FullName, Type = request.Type.ToString() };
                SignalHub.GetRequest(hubModel);
            }

            unitOfWork.Complete();
            if (User.IsInRole(RoleName.Administrator))
            {
                return(RedirectToAction("GetIndividuals"));
            }
            return(RedirectToAction("Index"));
        }