コード例 #1
0
        public ActionResult DonateProduct(DonateProductModel pm)
        {
            DataContext ctx = new DataContext(ConfigurationManager.ConnectionStrings["Cnstr"].ConnectionString);

            //if (ModelState.IsValid)
            //{
            if (pm == null)

            {
                ViewBag.Error = "Erreur";
                return(RedirectToAction("Index", "DonateProduct", new { area = "" }));
            }
            else
            {
                SessionUtils.ConnectedUser.DonateProduct = pm;

                ctx.InsertProduct(SessionUtils.ConnectedUser);
                return(RedirectToAction("Index", "Home", new { area = "" }));
            }


            //}
            //else
            //{
            //    return RedirectToAction("Index", "Home", new { area = "" });
            //}
        }
コード例 #2
0
        public List <DonateProductModel> SelectAllTypes()
        {
            List <DonateProductModel> dpm      = new List <DonateProductModel>();
            List <TypeEntity>         allTypes = _typeRepo.Get();

            foreach (TypeEntity type in allTypes)
            {
                DonateProductModel pm = new DonateProductModel();
                pm.Type   = type.Label;
                pm.IdType = type.IdType;
                dpm.Add(pm);
            }
            return(dpm);
        }
コード例 #3
0
        public List <DonateProductModel> GetProductsFromMembre(ProfilModel pm)
        {
            List <DonateProductModel>        dpm            = new List <DonateProductModel>();
            List <GetSixLatestPrductsEntity> productsMembre = ((GetSixLatestProductsRepository)_getSixRepo).GetAllProductsFromMembre(pm.IdUser);

            foreach (GetSixLatestPrductsEntity prod in productsMembre)
            {
                DonateProductModel dp = new DonateProductModel();
                dp.Nom             = prod.NomProduit;
                dp.Description     = prod.Description;
                dp.DateProposition = prod.DateProposition;
                dp.Bio             = prod.Bio;
                dp.Quantite        = prod.Quantite;
                dp.Type            = prod.Type;
                dp.DateProposition = prod.DatePeremption;
                dp.Marque          = prod.Marque;

                dpm.Add(dp);
            }
            return(dpm);
        }