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)); }
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)); }
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)); }
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)); }
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)); }
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; } }
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")); } }
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); } }
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); } } }
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)); }
public ActionResult Create(Product prod) { dc.Products.Add(prod); dc.SaveChanges(); return(RedirectToAction("Index", "Home")); }
public ActionResult Create(parametre param) { dc.parametres.Add(param); dc.SaveChanges(); return(PartialView()); }
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; } } }