Beispiel #1
0
        public ActionResult Synchronize(string PaymentNumber)
        {
            ViewBag.TopButtons = new List <TopButton> {
                new TopButton {
                    Direction = Enumerators.ButtonDirection.Left,
                    Link      = Url.Action("Index", "Home"),
                    Text      = "< Voltar"
                }
            };

            var loggedUser = (Session["loggedUSer"] as Customer);

            var billingGroup = _billingGroupBusiness.SelectSingle(
                w => w.UniqueIdentifier == PaymentNumber
                );

            IList <BillingGroup_Customer_Product> products = null;

            if (billingGroup != null && loggedUser != null)
            {
                var customer = new BillingGroup_Customer
                {
                    IdUser          = loggedUser.IdUser,
                    IdPaymentType   = (int)Enumerators.PaymentType.Master,
                    IndividualPrice = 0,
                    CreatedAt       = DateTime.Now,
                    IdBillingGroup  = billingGroup.IdBillingGroup
                };

                _billingGroupCustomerBusiness.Delete(customer);
                _billingGroupCustomerBusiness.Insert(customer);

                products = _billingGroupCustomerProductBusiness.Select(
                    p => p.IdBillingGroup == billingGroup.IdBillingGroup,
                    n => n.Product
                    );


                // return View(products);
            }
            else
            {
                this.ModelState.AddModelError(
                    "merchant-not-found",
                    "Estabelecimento não encontrado."
                    );
            }

            ViewBag.ViewCount = true;

            Session["products"] = products;
            return(View(products));
        }