Example #1
0
        public ActionResult Create([Bind(Include = "UserID,UserUsername,UserPassword,UserEmail,UserSalt,UserRegisterDate,UserLastLoginDate")] User user)
        {
            if (ModelState.IsValid)
            {
                db.Users.Add(user);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(user));
        }
Example #2
0
        public ActionResult Create([Bind(Include = "MediaID,MediaName,MediaAlt,MediaUrl,MediaTypeID")] Medium medium)
        {
            if (ModelState.IsValid)
            {
                db.Media.Add(medium);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.MediaTypeID = new SelectList(db.MediaTypes, "MediaTypeID", "MediaTypeName", medium.MediaTypeID);
            return(View(medium));
        }
Example #3
0
        public ActionResult Create([Bind(Include = "CustomerID,CustomerLastName,CustomerFirstName,CustomerCompany,CustomerActive,UserID")] Customer customer)
        {
            if (ModelState.IsValid)
            {
                db.Customers.Add(customer);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.UserID = new SelectList(db.Users, "UserID", "UserUsername", customer.UserID);
            return(View(customer));
        }
Example #4
0
        public ActionResult Create([Bind(Include = "PriceID,PriceDate,PriceValue,ProductID")] Price price)
        {
            if (ModelState.IsValid)
            {
                db.Prices.Add(price);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.ProductID = new SelectList(db.Products, "ProductID", "ProductName", price.ProductID);
            return(View(price));
        }
Example #5
0
        public ActionResult Create([Bind(Include = "AdressID,AdressCompany,AdressLine1,AdressLine2,AdressZipCode,AdressType,AdressActive,DeliverableCountryID,CustomerID")] Adress adress)
        {
            if (ModelState.IsValid)
            {
                db.Adresses.Add(adress);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            ViewBag.CustomerID           = new SelectList(db.Customers, "CustomerID", "CustomerLastName", adress.CustomerID);
            ViewBag.DeliverableCountryID = new SelectList(db.DeliverableCountries, "DeliverableCountryID", "DeliverableCountryName", adress.DeliverableCountryID);
            return(View(adress));
        }
Example #6
0
 public ActionResult Create(FormCollection collection, Category cat)
 {
     try
     {
         // TODO: Add insert logic here
         dc.Categories.Add(cat);
         dc.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Example #7
0
 public ActionResult Create(FormCollection collection, VATCategory vatcat)
 {
     try
     {
         // TODO: Add insert logic here
         dc.VATCategories.Add(vatcat);
         dc.SaveChanges();
         return(RedirectToAction("Index"));
     }
     catch
     {
         return(View("Index"));
     }
 }
Example #8
0
        public ActionResult Delete(CartItem ci)//d'abord suprrimer les dependances dela table prod comme prix par exemple
        {
            dc.Entry <CartItem>(ci).State = EntityState.Deleted;

            dc.SaveChanges();
            return(RedirectToAction("Index", "Home"));
        }
        public bool CreateAccount(User newUser)
        {
            using (vendrEntities dc = new vendrEntities())
            {
                dc.Users.Add(newUser);
                dc.SaveChanges();

                return(true);
            }
        }
Example #10
0
        public ActionResult Delete(Category cat, FormCollection collection)
        {
            try
            {
                // TODO: Add delete logic here

                dc.Entry <Category>(cat).State = EntityState.Deleted;

                dc.SaveChanges();
                return(RedirectToAction("Index"));
            }
            catch
            {
                return(View());
            }
        }
        //public override bool ConfirmAccount(string userName, string accountConfirmationToken)
        //{
        //    throw new NotImplementedException();
        //}

        public override string CreateAccount(string userName, string password, bool requireConfirmationToken)
        {
            using (vendrEntities dc = new vendrEntities())
            {
                if (requireConfirmationToken)
                {
                    User newUser = new User();
                    newUser.UserUsername = userName;
                    newUser.UserPassword = password;

                    dc.Users.Add(newUser);
                    dc.SaveChanges();
                    return(userName);
                }
                else
                {
                    return(null);
                }
            }
        }
Example #12
0
        public async Task <ActionResult> Register(RegisterViewModel model)
        {
            if (ModelState.IsValid)
            {
                var user = new ApplicationUser {
                    UserName = model.Email, Email = model.Email
                };
                var result = await UserManager.CreateAsync(user, model.Password);

                if (result.Succeeded)
                {
                    var code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id);

                    var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme);
                    await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking this link: <a href=\"" + callbackUrl + "\">link</a>");

                    ViewBag.Link = callbackUrl;
                    //on crée autom son analogue dans la table User de la db MyShop
                    User dbuser = new User();
                    dbuser.UserUsername = model.Email;
                    string hash = FormsAuthentication.HashPasswordForStoringInConfigFile(model.Password, "md5");
                    //string hash=Crypt(model.Password);
                    dbuser.UserPassword = hash;
                    dbuser.UserEmail    = model.Email;
                    dbuser.UserSalt     = "123";
                    //dbuser.ro = 1;

                    dbuser.UserRegisterDate = DateTime.Now;
                    dc.Users.Add(dbuser);
                    dc.SaveChanges();
                    return(View("DisplayEmail"));
                }
                AddErrors(result);
            }

            // If we got this far, something failed, redisplay form
            return(View(model));
        }
Example #13
0
 public ActionResult Create(Product prod)
 {
     dc.Products.Add(prod);
     dc.SaveChanges();
     return(RedirectToAction("Index", "Home"));
 }
Example #14
0
 public ActionResult Create(parametre param)
 {
     dc.parametres.Add(param);
     dc.SaveChanges();
     return(PartialView());
 }
Example #15
0
        private void FromSessionToDb()
        {
            //récupérer le userid
            string email  = dbc.Users.Where(u => u.Email == User.Identity.Name).First().Email;
            int    userId = dc.Users.Where(u => u.UserEmail == User.Identity.Name).First().UserID;

            // récupérer toute les commandelines dont command status = 1 et user id = user loggé
            List <CommandLine> lstcmdline = (from cl in dc.CommandLines
                                             join c in dc.Commands on cl.CommandID equals c.CommandID
                                             join u in dc.Users on c.Adress.Customer.UserID equals u.UserID
                                             where u.UserEmail == email
                                             select cl).ToList();

            int cmdid = 0;

            foreach (CommandLine c in lstcmdline)
            {
                if (cmdid == 0)
                {
                    cmdid = c.CommandID;
                }
                dc.CommandLines.Remove(c);
            }

            try
            {
                dc.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }

            //insertion db
            if (Utils.sessionCart.CartLine != null && Utils.sessionCart.CartLine.Count > 0)
            {
                try
                {
                    Command cmd = new Command();
                    // cmd.Adress.Customer.UserID = userId;
                    cmd.CommandDate       = DateTime.Now;
                    cmd.CommandeReference = "jbfkjbkjbjf";
                    cmd.CommandFicsalDate = Convert.ToDateTime("2017 - 02 - 28 19:06:45.943");
                    cmd.CommandStatusID   = 1;
                    cmd.Adress            = dc.Adresses.Where(x => x.Customer.UserID == userId).First();
                    dc.Commands.Add(cmd);
                    dc.SaveChanges();

                    foreach (KeyValuePair <int, CartItem> ci in Utils.sessionCart.CartLine)
                    {
                        CommandLine cl = new CommandLine();

                        cl.CommandLinePrice    = ci.Value.price;
                        cl.ProductID           = ci.Value.productid;
                        cl.CommandLineQuantity = ci.Value.quantity;
                        cl.CommandID           = cmd.CommandID;

                        dc.CommandLines.Add(cl);
                    }

                    dc.SaveChanges();
                }
                catch (DbEntityValidationException e)
                {
                    throw e;
                }
            }
        }