public ActionResult AddCategory([Bind(Include = "id,activeFlag,createDate,updateDate")] category categorys, int parentId, string name, string code, string description) { categorys.parentId = parentId; categorys.name = name; categorys.code = code; categorys.description = description; categorys.activeFlag = 1; categorys.createDate = DateTime.Now; categorys.updateDate = DateTime.Now; db.categories.Add(categorys); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Add([Bind(Include = "id,activeFlag,createDate,updateDate")] product product2, int catagoryId, int brandId, string name, HttpPostedFileBase imgMain, string code, string description) { string fileName = System.IO.Path.GetFileName(imgMain.FileName); string urlImage = Server.MapPath("~/Image/product/" + fileName); imgMain.SaveAs(urlImage); product2.imgMain = "Image/product/" + fileName; product2.brandId = brandId; product2.catagoryId = catagoryId; product2.name = name; product2.code = code; product2.description = description; product2.activeFlag = 1; product2.createDate = DateTime.Now; product2.updateDate = DateTime.Now; db.products.Add(product2); db.SaveChanges(); return(RedirectToAction("Index")); /* try * { * string fileName = System.IO.Path.GetFileName(imgMain.FileName); * string urlImage = Se00rver.MapPath("~/Image/product/" + fileName); * imgMain.SaveAs(urlImage); * product.brandId = brandId; * product.catagoryId = catagoryId; * product.code = code; * product.description = description; * product.activeFlag = 1; * product.createDate = DateTime.Now; * product.updateDate = DateTime.Now; * db.products.Add(product); * db.SaveChanges(); * return RedirectToAction("Index"); * * } * catch (DbEntityValidationException dbEx) * { * foreach (var validationErrors in dbEx.EntityValidationErrors) * { * foreach (var validationError in validationErrors.ValidationErrors) * { * System.Console.WriteLine("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage); * } * } * } * return RedirectToAction("Add"); */ }
public ActionResult addBrand([Bind(Include = "id,activeFlag,createDate,updateDate")] brand brands, string name, HttpPostedFileBase logo) { string fileName = System.IO.Path.GetFileName(logo.FileName); string urlImage = Server.MapPath("~/Image/logo/" + fileName); logo.SaveAs(urlImage); brands.logo = "Image/logo/" + fileName; brands.name = name; brands.activeFlag = 1; brands.createDate = DateTime.Now; brands.updateDate = DateTime.Now; db.brands.Add(brands); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Register([Bind(Exclude = "activeFlag")] user user) { bool Status = false; String Message = ""; //model validation if (ModelState.IsValid) { #region //email is already Exits var isExist = IsEmailExist(user.email); if (isExist) { ModelState.AddModelError("EmailExist", "Email already exist"); return(View(user)); } #endregion #region Generate activeFlag user.activeFlag = 0; user.createDate = DateTime.Now; user.updateDate = DateTime.Now; #endregion #region password hashing user.password = UtilPass.Hash(user.password); #endregion #region Save data database using (dotnetstorephoneEntities phone_Store = new dotnetstorephoneEntities()) { phone_Store.users.Add(user); phone_Store.SaveChanges(); //Send Email user SendVerificationSendLinkEmail(user.email, user.id); Message = "We have sent you a confirmation link at the email:" + user.email + ".Please confirm!"; Status = true; /*return RedirectToAction("Login", "MyUser");*/ } #endregion } else { Message = "Invalid Request"; } ViewBag.Message = Message; ViewBag.Status = Status; return(View(user)); }
public ActionResult Add([Bind(Include = "id,activeFlag,createDate,updateDate")] product product, int catagoryId, int brandId, HttpPostedFileBase imgMain, string code, string description) { string fileName = System.IO.Path.GetFileName(imgMain.FileName); string urlImage = Server.MapPath("~/Image/product/" + fileName); imgMain.SaveAs(urlImage); product.brandId = brandId; product.catagoryId = catagoryId; product.code = code; product.description = description; product.activeFlag = 1; product.createDate = DateTime.Now; product.updateDate = DateTime.Now; db.products.Add(product); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult VeryAccount(int id) { bool Status = false; using (dotnetstorephoneEntities phone = new dotnetstorephoneEntities()) { var v = phone.users.Where(a => a.id == id).FirstOrDefault(); System.Diagnostics.Debug.WriteLine("gggg" + v); if (v != null) { v.activeFlag = 1; phone.SaveChanges(); Status = true; } else { ViewBag.Message = "Invalid Request!"; } } ViewBag.Status = Status; return(View()); }
public ActionResult addBrand([Bind(Include = "id,activeFlag,createDate,updateDate")] brand brands, string name, HttpPostedFileBase logo) { /* string fileName = System.IO.Path.GetFileName(logo.FileName); * string urlImage = Server.MapPath("~/Image/logo/" + fileName); * logo.SaveAs(urlImage); * brands.logo = "Image/logo/" + fileName; * brands.name = name; * brands.activeFlag = 1; * brands.createDate = DateTime.Now; * brands.updateDate = DateTime.Now; * db.brands.Add(brands); * db.SaveChanges(); * return RedirectToAction("Index");*/ /* string fileName = System.IO.Path.GetFileName(logo.FileName); * string urlImage = Server.MapPath("~/Image/logo/" + fileName); * logo.SaveAs(urlImage); * brands.logo = "Image/logo/" + fileName; * brands.name = name; * brands.activeFlag = 1; * brands.createDate = DateTime.Now; * brands.updateDate = DateTime.Now; * db.brands.Add(brands); * db.SaveChanges(); * return RedirectToAction("Index");*/ /*if (ModelState.IsValid) * { * * * } * else * { * if(logo !=null && logo.ContentLength>0) * { * string fileName = System.IO.Path.GetFileName(logo.FileName); * string urlImage = Server.MapPath("~/Image/logo/" + fileName); * logo.SaveAs(urlImage); * brands.logo = "Image/logo/" + fileName; * brands.name = name; * brands.activeFlag = 1; * brands.createDate = DateTime.Now; * brands.updateDate = DateTime.Now; * db.brands.Add(brands); * db.SaveChanges(); * return RedirectToAction("Index");*/ if (logo != null && logo.ContentLength > 0) { string fileName = System.IO.Path.GetFileName(logo.FileName); string urlImage = Server.MapPath("~/Image/logo/" + fileName); logo.SaveAs(urlImage); brands.logo = "Image/logo/" + fileName; brands.name = name; brands.activeFlag = 1; brands.createDate = DateTime.Now; brands.updateDate = DateTime.Now; db.brands.Add(brands); db.SaveChanges(); return(RedirectToAction("Index")); } if (ModelState.IsValid) { } return(View(brands)); }