コード例 #1
0
        public ActionResult AddCymbalToCart(List <CymbalPO> cymbalList)
        {
            if (Session["AccountID"] != null)
            {
                ProductModel cart         = new ProductModel();
                ProductModel productModel = new ProductModel();
                if (Session["ShoppingCart"] == null)
                {
                    Session["ShoppingCart"] = cart;
                }
                cart = (ProductModel)Session["ShoppingCart"];
                foreach (CymbalPO cymbal in cymbalList)
                {
                    CymbalPO cymbalPO = new CymbalPO();
                    cymbalPO             = MappingMethods.MapCymbalDOtoPO(dataMethods.GetCymbalInfoByID(cymbal.CymbalID));
                    cymbalPO.CheckoutQty = cymbal.CheckoutQty;

                    if (cymbal.CheckoutQty > 0 && cymbal.CheckoutQty <= cymbal.CymbalQuantity)
                    {
                        cart.cymbalList.Add(cymbalPO);
                    }
                    else
                    {
                    }
                }

                Session["ShoppingCart"] = cart;
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }

            return(RedirectToAction("BrowseCymbals", "Store"));
        }
コード例 #2
0
        public ActionResult Login(AccountModel accountModel)
        {
            if (accountModel.aAccount.UserName != null)
            {
                accountModel.aAccount.PassWord = bllMethods.PassWordHash(accountModel.aAccount.PassWord);
                AccountDO accountDO = dataMethods.GetAccountInfoByUserName(accountModel.aAccount.UserName);


                if (ModelState.IsValid)
                {
                    if (accountModel.aAccount.PassWord == accountDO.PassWord)
                    {
                        accountModel.aAccount = MappingMethods.MapAccountDOtoPO(accountDO);
                        Session["RoleID"]     = accountModel.aAccount.RoleID;
                        Session["AccountID"]  = accountModel.aAccount.AccountID;
                        Session["FirstName"]  = accountModel.aAccount.FirstName;
                        Session["LastName"]   = accountModel.aAccount.LastName;
                        Session["Email"]      = accountModel.aAccount.Email;


                        return(View("Index"));
                    }
                    else
                    {
                        ModelState.AddModelError("", "Username or Password is invalid.");
                    }
                }
            }

            return(View());
        }
コード例 #3
0
        public ActionResult UpdateAccount(int AccountID)
        {
            AccountModel viewModel = new AccountModel();

            viewModel.aAccount           = MappingMethods.MapAccountDOtoPO(dataMethods.GetAccountInfoByID(AccountID));
            viewModel.aAccount.AccountID = AccountID;
            return(View(viewModel));
        }
コード例 #4
0
        public ActionResult UpdateDrumProduct(int DrumID)
        {
            ProductModel drumModel = new ProductModel();

            drumModel.aDrum        = MappingMethods.MapDrumDOtoPO(dataMethods.GetDrumInfoByID(DrumID));
            drumModel.aDrum.DrumID = DrumID;
            return(View(drumModel));
        }
コード例 #5
0
        public ActionResult UpdateCymbalProduct(int cymbalID)
        {
            ProductModel cymbalModel = new ProductModel();

            cymbalModel.aCymbal          = MappingMethods.MapCymbalDOtoPO(dataMethods.GetCymbalInfoByID(cymbalID));
            cymbalModel.aCymbal.CymbalID = cymbalID;
            return(View(cymbalModel));
        }
コード例 #6
0
        public ActionResult AddCymbalProduct(ProductModel cymbalModel)
        {
            cymbalModel.aCymbal.AccountID = (int)Session["AccountID"];
            CymbalDO cymbalDO = MappingMethods.MapCymbalPOtoDO(cymbalModel.aCymbal);

            dataMethods.CreateCymbal(cymbalDO);

            return(RedirectToAction("ViewProducts", "StoreManager"));
        }
コード例 #7
0
        private Expression CreateItemEqualityExpression(MemberExpression fromItem, MemberExpression toItem)
        {
            Expression itemsAreMapEqual;

            if (this.aItemMapping.ResolvedMapping is IMappingWithSpecialComparision)
            {
                itemsAreMapEqual = Expression.Call(
                    Expression.Constant(this.aItemMapping.ResolvedMapping),
                    MappingMethods.MapEqual(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                    fromItem,
                    toItem
                    );
            }
            else
            {
                Expression fromMapped = fromItem;

                if (!(this.aItemMapping.ResolvedMapping is IDirectMapping))
                {
                    fromMapped = Expression.Call(
                        Expression.Constant(this.aItemMapping.ResolvedMapping),
                        MappingMethods.Map(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                        fromMapped
                        );
                }

                itemsAreMapEqual = Expression.Call(
                    Expression.Constant(EqualityComparerMethods.GetEqualityComparer(EnumerableReflection <TTo> .ItemType)),
                    EqualityComparerMethods.Equals(EnumerableReflection <TTo> .ItemType),
                    fromMapped,
                    toItem
                    );
            }

            if (this.aEqualityRules != null)
            {
                var(selectIdFrom, selectIdTo) = this.aEqualityRules.GetIdSelectors();
                itemsAreMapEqual = Expression.AndAlso(
                    Expression.Equal(
                        ExpressionHelper.Call(
                            selectIdFrom,
                            fromItem
                            ),
                        ExpressionHelper.Call(
                            selectIdTo,
                            toItem
                            )
                        ),
                    itemsAreMapEqual
                    );
            }

            return(itemsAreMapEqual);
        }
コード例 #8
0
 public ActionResult UpdateDrumProduct(ProductModel drumModel)
 {
     if (ModelState.IsValid)
     {
         dataMethods.UpdateDrum(MappingMethods.MapDrumPOtoDO(drumModel.aDrum));
         return(RedirectToAction("ViewProducts", "StoreManager"));
     }
     else
     {
         return(View());
     }
 }
コード例 #9
0
 private SwitchCase MakeIfConvertSynchronizeStatement(Type fromType, Type toType, IMapping mapping, ParameterExpression from, ParameterExpression to)
 {
     return(Expression.SwitchCase(
                Expression.Call(
                    Expression.Constant(mapping),
                    MappingMethods.Synchronize(fromType, toType),
                    Expression.Convert(from, fromType),
                    Expression.Convert(to, toType)
                    ),
                Expression.Constant(fromType)
                ));
 }
コード例 #10
0
 public ActionResult RemoveDrumFromCart(int drumID)
 {
     if (Session["ShoppingCart"] != null)
     {
         ProductModel cart         = new ProductModel();
         ProductModel productModel = new ProductModel();
         productModel.aDrum = MappingMethods.MapDrumDOtoPO(dataMethods.GetDrumInfoByID(drumID));
         cart = (ProductModel)Session["ShoppingCart"];
         cart.drumList.RemoveAll(x => x.DrumID == productModel.aDrum.DrumID);
         Session["ShoppingCart"] = cart;
     }
     return(RedirectToAction("ViewCart", "Store"));
 }
コード例 #11
0
 public ActionResult RemoveCymbalFromCart(int cymbalID)
 {
     if (Session["ShoppingCart"] != null)
     {
         ProductModel cart         = new ProductModel();
         ProductModel productModel = new ProductModel();
         productModel.aCymbal = MappingMethods.MapCymbalDOtoPO(dataMethods.GetCymbalInfoByID(cymbalID));
         cart = (ProductModel)Session["ShoppingCart"];
         cart.cymbalList.RemoveAll(x => x.CymbalID == productModel.aCymbal.CymbalID);
         Session["ShoppingCart"] = cart;
     }
     return(RedirectToAction("ViewCart", "Store"));
 }
コード例 #12
0
        public ActionResult ViewAccounts()
        {
            AccountModel     viewModel     = new AccountModel();
            List <AccountDO> accountDOList = dataMethods.ViewAllAccounts();

            foreach (AccountDO accountDO in accountDOList)
            {
                AccountPO accountPO = new AccountPO();
                accountPO = MappingMethods.MapAccountDOtoPO(accountDO);
                viewModel.accountList.Add(accountPO);
            }
            return(View(viewModel));
        }
コード例 #13
0
        public ActionResult BrowseCymbals()
        {
            ProductModel    productModel = new ProductModel();
            List <CymbalDO> cymbalDOList = dataMethods.ViewAllCymbals();

            foreach (CymbalDO cymbalDO in cymbalDOList)
            {
                CymbalPO cymbalPO = new CymbalPO();
                cymbalPO = MappingMethods.MapCymbalDOtoPO(cymbalDO);
                productModel.cymbalList.Add(cymbalPO);
            }

            return(View(productModel.cymbalList));
        }
コード例 #14
0
        public ActionResult BrowseDrums()
        {
            ProductModel  productModel = new ProductModel();
            List <DrumDO> drumDOList   = dataMethods.ViewAllDrums();

            foreach (DrumDO drumDO in drumDOList)
            {
                DrumPO drumPO = new DrumPO();
                drumPO = MappingMethods.MapDrumDOtoPO(drumDO);
                productModel.drumList.Add(drumPO);
            }

            return(View(productModel.drumList));
        }
コード例 #15
0
 public ActionResult RegisterAccount(AccountModel viewModel)
 {
     if (ModelState.IsValid)
     {
         viewModel.aAccount.PassWord = bllMethods.PassWordHash(viewModel.aAccount.PassWord);
         AccountDO accountDO = MappingMethods.MapAccountPOtoDO(viewModel.aAccount);
         dataMethods.CreateAccount(accountDO);
         return(RedirectToAction("Login", "Home"));
     }
     else
     {
         return(View());
     }
 }
コード例 #16
0
        public ActionResult AddDrumProduct(ProductModel drumModel)
        {
            if (ModelState.IsValid)
            {
                drumModel.aDrum.AccountID = (int)Session["AccountID"];
                DrumDO drumDO = MappingMethods.MapDrumPOtoDO(drumModel.aDrum);
                dataMethods.CreateDrum(drumDO);


                return(RedirectToAction("ViewProducts", "StoreManager"));
            }
            else
            {
                return(View());
            }
        }
コード例 #17
0
        public ActionResult ViewCart()
        {
            ProductModel productModel = new ProductModel();

            if (Session["ShoppingCart"] != null)
            {
                productModel = (ProductModel)Session["ShoppingCart"];
                BusinessModel businessModel = MappingMethods.MapProductModeltoBusinessModel(productModel);
                productModel           = MappingMethods.MapBusinessModeltoProductModel(businessModel);
                productModel.CartTotal = bllMethods.CalculateTotalPrice(businessModel);
            }
            else if (Session["AccountID"] == null)
            {
                return(RedirectToAction("Login", "Home"));
            }

            return(View(productModel));
        }
コード例 #18
0
        private Expression CreateItemMappingExpression(ParameterExpression from)
        {
            if (this.aItemMapping.ResolvedMapping is IDirectMapping)
            {
                return(from);
            }

            var mapMethod = Delegate.CreateDelegate(
                typeof(Func <,>).MakeGenericType(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                this.aItemMapping.ResolvedMapping,
                MappingMethods.Map(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType)
                );

            return(Expression.Call(null, LinqMethods.Select(EnumerableReflection <TFrom> .ItemType, EnumerableReflection <TTo> .ItemType),
                                   from,
                                   Expression.Constant(mapMethod)
                                   ));
        }
コード例 #19
0
ファイル: PairedMembers.cs プロジェクト: frikst/POCOMapper
        public Expression CreateComparisionExpression(ParameterExpression from, ParameterExpression to, LabelTarget end)
        {
            if (this.Mapping.ResolvedMapping is IMappingWithSpecialComparision)
            {
                return(Expression.IfThen(
                           Expression.Not(
                               Expression.Call(
                                   Expression.Constant(this.Mapping.ResolvedMapping),
                                   MappingMethods.MapEqual(this.From.Type, this.To.Type),
                                   this.From.CreateGetterExpression(from),
                                   this.To.CreateGetterExpression(to)
                                   )
                               ),
                           Expression.Return(end, Expression.Constant(false))
                           ));
            }
            else
            {
                var fromMapped = this.From.CreateGetterExpression(from);

                if (!(this.Mapping.ResolvedMapping is IDirectMapping))
                {
                    fromMapped = Expression.Call(
                        Expression.Constant(this.Mapping.ResolvedMapping),
                        MappingMethods.Map(this.From.Type, this.To.Type),
                        fromMapped
                        );
                }

                return(Expression.IfThen(
                           Expression.Not(
                               Expression.Call(
                                   Expression.Constant(EqualityComparerMethods.GetEqualityComparer(this.To.Type)),
                                   EqualityComparerMethods.Equals(this.To.Type),
                                   fromMapped,
                                   this.To.CreateGetterExpression(to)
                                   )
                               ),
                           Expression.Return(end, Expression.Constant(false))
                           ));
            }
        }
コード例 #20
0
ファイル: PairedMembers.cs プロジェクト: frikst/POCOMapper
        public Expression CreateMappingAssignmentExpression(ParameterExpression from, ParameterExpression to, Delegate postprocess, ParameterExpression parent)
        {
            Expression ret = this.From.CreateGetterExpression(from);

            if (!(this.Mapping.ResolvedMapping is IDirectMapping))
            {
                ret = Expression.Call(
                    Expression.Constant(this.Mapping.ResolvedMapping),
                    MappingMethods.Map(this.From.Type, this.To.Type),
                    ret
                    );
            }

            ret = this.To.CreateSetterExpression(
                to,
                ret
                );

            return(this.AddPostprocess(ret, to, postprocess, parent));
        }
コード例 #21
0
        public ActionResult AddDrumToCart(List <DrumPO> drumList)
        {
            if (Session["AccountID"] != null)
            {
                ProductModel cart         = new ProductModel();
                ProductModel productModel = new ProductModel();
                if (Session["ShoppingCart"] == null)
                {
                    Session["ShoppingCart"] = cart;
                }
                cart = (ProductModel)Session["ShoppingCart"];
                foreach (DrumPO drum in drumList)
                {
                    DrumPO drumPO = new DrumPO();
                    drumPO             = MappingMethods.MapDrumDOtoPO(dataMethods.GetDrumInfoByID(drum.DrumID));
                    drumPO.CheckoutQty = drum.CheckoutQty;

                    if (drum.CheckoutQty > 0 && drum.CheckoutQty <= drum.DrumQuantity)
                    {
                        cart.drumList.Add(drumPO);
                    }
                    else
                    {
                    }
                }

                //productModel.aDrum = MappingMethods.MapDrumDOtoPO(dataMethods.GetDrumInfoByID(drumID));
                //productModel.aDrum.DrumID = drumID;

                Session["ShoppingCart"] = cart;
            }
            else
            {
                return(RedirectToAction("Login", "Home"));
            }

            return(RedirectToAction("BrowseDrums", "Store"));
        }
コード例 #22
0
        public ActionResult PlaceOrder()
        {
            ProductModel cart = new ProductModel();

            cart = (ProductModel)Session["ShoppingCart"];
            foreach (DrumPO drum in cart.drumList)
            {
                DrumDO drumDO = new DrumDO();
                drumDO = MappingMethods.MapDrumPOtoDO(drum);
                dataMethods.UpdateDrumQuantity(drum.DrumID, drum.CheckoutQty);
                DrumPO drumPO = MappingMethods.MapDrumDOtoPO(drumDO);
            }
            foreach (CymbalPO cymbal in cart.cymbalList)
            {
                CymbalDO cymbalDO = new CymbalDO();
                cymbalDO = MappingMethods.MapCymbalPOtoDO(cymbal);
                dataMethods.UpdateCymbalQty(cymbal.CymbalID, cymbal.CheckoutQty);
                CymbalPO cymbalPO = MappingMethods.MapCymbalDOtoPO(cymbalDO);
            }
            cart.cymbalList.Clear();
            cart.drumList.Clear();
            return(View());
        }
コード例 #23
0
        public ActionResult ViewProducts()
        {
            ProductModel  productModel = new ProductModel();
            List <DrumDO> drumDOList   = dataMethods.ViewAllDrums();

            foreach (DrumDO drumDO in drumDOList)
            {
                DrumPO drumPO = new DrumPO();
                drumPO = MappingMethods.MapDrumDOtoPO(drumDO);
                productModel.drumList.Add(drumPO);
            }

            List <CymbalDO> cymbalDOList = dataMethods.ViewAllCymbals();

            foreach (CymbalDO cymbalDO in cymbalDOList)
            {
                CymbalPO cymbalPO = new CymbalPO();
                cymbalPO = MappingMethods.MapCymbalDOtoPO(cymbalDO);
                productModel.cymbalList.Add(cymbalPO);
            }


            return(View(productModel));
        }
コード例 #24
0
 public ActionResult UpdateCymbalProduct(ProductModel cymbalModel)
 {
     dataMethods.UpdateCymbal(MappingMethods.MapCymbalPOtoDO(cymbalModel.aCymbal));
     return(RedirectToAction("ViewProducts", "StoreManager"));
 }
コード例 #25
0
 public ActionResult UpdateAccount(AccountModel viewModel)
 {
     viewModel.aAccount.PassWord = bllMethods.PassWordHash(viewModel.aAccount.PassWord);
     dataMethods.UpdateAccountAdmin(MappingMethods.MapAccountPOtoDO(viewModel.aAccount));
     return(RedirectToAction("ViewAccounts", "Admin"));
 }
コード例 #26
0
ファイル: PairedMembers.cs プロジェクト: frikst/POCOMapper
        public Expression CreateSynchronizationAssignmentExpression(ParameterExpression from, ParameterExpression to, Delegate postprocess, ParameterExpression parent)
        {
            IMappingWithSyncSupport mappingWithSync = this.Mapping.ResolvedMapping as IMappingWithSyncSupport;

            if (mappingWithSync == null)
            {
                return(this.CreateMappingAssignmentExpression(from, to, postprocess, parent));
            }

            ParameterExpression tempFromValue = Expression.Parameter(this.From.Type, "tempFrom");
            ParameterExpression tempToValue   = Expression.Parameter(this.To.Type, "tempTo");

            if (!this.To.Readable)
            {
                // TODO: ???
                throw new InvalidMappingException($"Cannot synchronize object with setter method mapping destination without any getter method defined for {this.To} member of {this.To.DeclaringType} type");
            }

            Expression synchronize = Expression.Call(
                Expression.Constant(mappingWithSync),
                MappingMethods.Synchronize(this.From.Type, this.To.Type),
                tempFromValue, tempToValue
                );

            if (mappingWithSync.SynchronizeCanChangeObject)
            {
                if (!this.To.Writable)
                {
                    throw new InvalidMappingException($"Cannot synchronize non writtable member {this.To} using mapping {mappingWithSync.GetType().Name}");
                }

                if (postprocess != null)
                {
                    var origToValue = Expression.Parameter(this.To.Type, "origTo");
                    var newToValue  = Expression.Parameter(this.To.Type, "newTo");

                    synchronize = Expression.Block(
                        new[] { origToValue, newToValue },
                        Expression.Assign(origToValue, tempToValue),
                        Expression.Assign(newToValue, synchronize),
                        Expression.IfThen(
                            ExpressionHelper.NotSame(origToValue, newToValue),
                            ExpressionHelper.Call(postprocess, parent, newToValue)
                            ),
                        this.To.CreateSetterExpression(
                            to,
                            newToValue
                            )
                        );
                }
                else
                {
                    synchronize = this.To.CreateSetterExpression(
                        to,
                        synchronize
                        );
                }
            }

            return(Expression.Block(
                       new ParameterExpression[] { tempFromValue, tempToValue },
                       Expression.Assign(tempFromValue, this.From.CreateGetterExpression(from)),
                       Expression.Assign(tempToValue, this.To.CreateGetterExpression(to)),
                       synchronize
                       ));
        }