public ActionResult Edit(SubFeature subFeature) { if (ModelState.IsValid) { db.Entry(subFeature).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index", new { featureId = subFeature.FeatureId })); } return(View(subFeature)); }
public ActionResult Edit(Feature feature) { if (ModelState.IsValid) { db.Entry(feature).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(feature)); }
public ActionResult ProfileEdit([Bind(Include = "Id,RoleId,UserCode,UserFirstName,UserLastName,UserFatherName,UserImage,UserDateofBirth,UserNationalCode,UserPostalCode,UserPhoneNumber,UserEmail,UserPassword,UserVerificationCode,UserIdentifierCode,IsActive,UserAddress,UserLandlinePhone")] User user, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { Random randomm = new Random(); string imgcode = randomm.Next(100000, 999999).ToString(); file.SaveAs(HttpContext.Server.MapPath("~/Images/User/") + imgcode.ToString() + "-" + file.FileName); user.UserImage = imgcode.ToString() + "-" + file.FileName; } Random random = new Random(); int MyUserCode = random.Next(10000000, 99000000); int MyVerificationCode = 0; bool isValidCod = false; while (!isValidCod) { Random random1 = new Random(); MyVerificationCode = random1.Next(100000, 990000); var userverificationcode = db.Users.FirstOrDefault(j => j.UserVerificationCode == MyVerificationCode.ToString()); if (userverificationcode == null) { isValidCod = true; } } user.UserPassword = user.UserPassword; user.UserVerificationCode = MyVerificationCode.ToString(); user.UserCode = MyUserCode.ToString(); user.RoleId = user.RoleId; user.IsActive = user.IsActive; db.Entry(user).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.RoleId = new SelectList(db.Roles, "Id", "RoleName", user.RoleId); return(View(user)); }
public SystemParameter Save(SystemParameter entity) { if (entity.Id == 0) { db.SystemParameters.Add(entity); db.SaveChanges(); } else { db.Set <SystemParameter>().Attach(entity); db.Entry(entity).State = EntityState.Modified; db.SaveChanges(); } return(entity); }
public ActionResult Edit([Bind(Include = "Id,Name,Icon,Link,Order,NotShow")] SocialNetWork socialNetWork) { if (ModelState.IsValid) { socialNetWork.InsertUser = "******"; socialNetWork.InsertDate = DateTime.Now; socialNetWork.UpdateUser = "******"; socialNetWork.UpdateDate = DateTime.Now; socialNetWork.IsArchived = false; socialNetWork.IsDeleted = false; db.Entry(socialNetWork).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(socialNetWork)); }
public ActionResult Edit([Bind(Include = "Id,Header,NotShow")] IdeaHeader ideaHeader) { if (ModelState.IsValid) { ideaHeader.InsertUser = "******"; ideaHeader.InsertDate = DateTime.Now; ideaHeader.UpdateUser = "******"; ideaHeader.UpdateDate = DateTime.Now; ideaHeader.IsArchived = false; ideaHeader.IsDeleted = false; db.Entry(ideaHeader).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(ideaHeader)); }
public ActionResult Edit([Bind(Include = "Id,BrandName,BrandImg,BrandOrder,BrandNotShow")] Brand brand, HttpPostedFileBase file) { if (file != null) { Random random = new Random(); string imgcode = random.Next(100000, 999999).ToString(); file.SaveAs(HttpContext.Server.MapPath("~/Images/Brand/") + imgcode.ToString() + "-" + file.FileName); brand.BrandImg = imgcode.ToString() + "-" + file.FileName; } //brand.InsertUser = "******"; //brand.InsertDate = DateTime.Now; //brand.UpdateUser = "******"; //brand.UpdateDate = DateTime.Now; //brand.IsArchived = false; //brand.IsDeleted = false; db.Entry(brand).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "Id,Image,Address,Tel,Email,AboutUs,ShortAboutUs,NotShow")] ContactUs contactUs, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { Random randomm = new Random(); string imgcode = randomm.Next(100000, 999999).ToString(); file.SaveAs(HttpContext.Server.MapPath("~/Images/AboutUs/") + imgcode.ToString() + "-" + file.FileName); contactUs.Image = imgcode.ToString() + "-" + file.FileName; } contactUs.InsertUser = "******"; contactUs.InsertDate = DateTime.Now; contactUs.UpdateUser = "******"; contactUs.UpdateDate = DateTime.Now; contactUs.IsArchived = false; contactUs.IsDeleted = false; db.Entry(contactUs).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(contactUs)); }
public ActionResult Edit([Bind(Include = "Id,SliderTitle,SliderSubTitle,SliderDescription,SliderImg,SliderUrl,SliderOrder,SliderNotShow")] SliderHeader sliderHeader, HttpPostedFileBase file) { if (ModelState.IsValid) { if (file != null) { Random random = new Random(); string imgcode = random.Next(100000, 999999).ToString(); file.SaveAs(HttpContext.Server.MapPath("~/Images/SliderHeader/") + imgcode.ToString() + "-" + file.FileName); sliderHeader.SliderImg = imgcode.ToString() + "-" + file.FileName; } sliderHeader.InsertUser = "******"; sliderHeader.InsertDate = DateTime.Now; sliderHeader.UpdateUser = "******"; sliderHeader.UpdateDate = DateTime.Now; sliderHeader.IsArchived = false; sliderHeader.IsDeleted = false; db.Entry(sliderHeader).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(sliderHeader)); }
public int?Edit(NewProductViewModel product) { if (!ModelState.IsValid) { return(null); } var prod = db.Products.Find(product.Id.Value); prod.ProductName = product.ProductName; prod.ProductShortDescription = product.ProductShortDescription; prod.ProductDescription = prod.ProductDescription; prod.BrandId = product.Brand; prod.ProductGroupId = product.ProductGroup; prod.ProductPrice = product.ProductPrice; prod.ProductDiscountPercent = product.ProductDiscountPercent; prod.Point = product.Point; db.Entry(prod).State = EntityState.Modified; db.SaveChanges(); #region Removing Previous Product Features var productMainFeatures = db.ProductMainFeatures.Where(f => f.ProductId == prod.Id).ToList(); foreach (var mainFeature in productMainFeatures) { db.ProductMainFeatures.Remove(mainFeature); } db.SaveChanges(); var productFeatures = db.ProductFeatureValues.Where(f => f.ProductId == prod.Id).ToList(); foreach (var feature in productFeatures) { db.ProductFeatureValues.Remove(feature); } db.SaveChanges(); #endregion #region Adding Product Features foreach (var feature in product.ProductFeatures) { if (feature.IsMain) { var model = new ProductMainFeature(); model.ProductId = prod.Id; model.FeatureId = feature.FeatureId; model.SubFeatureId = feature.SubFeatureId; model.Value = feature.Value; model.Quantity = feature.Quantity ?? 0; model.Price = feature.Price ?? 0; db.ProductMainFeatures.Add(model); db.SaveChanges(); } else { var model = new ProductFeatureValue(); model.ProductId = prod.Id; model.FeatureId = feature.FeatureId; model.SubFeatureId = feature.SubFeatureId; model.Value = feature.Value; db.ProductFeatureValues.Add(model); db.SaveChanges(); } } #endregion return(prod.Id); }
public int?Edit(UpdateProductGroupViewModel newProductGroup) { if (ModelState.IsValid) { var productGroup = db.ProductGroups.Find(newProductGroup.Id); #region Adding Product Group productGroup.GroupName = newProductGroup.GroupName; if (newProductGroup.ParentGroupId != 0) { productGroup.ParentId = newProductGroup.ParentGroupId; } else { productGroup.ParentId = null; } db.Entry(productGroup).State = EntityState.Modified; db.SaveChanges(); #endregion #region Product Group Brands // Removing Previous Group Brands var productGroupBrands = db.ProductGroupBrands .Where(b => b.ProductGroupId == productGroup.Id).ToList(); foreach (var item in productGroupBrands) { db.ProductGroupBrands.Remove(item); } db.SaveChanges(); // Adding new Group Brands foreach (var brandId in newProductGroup.BrandIds) { var productGroupBrand = new ProductGroupBrand(); productGroupBrand.ProductGroupId = productGroup.Id; productGroupBrand.BrandId = brandId; db.ProductGroupBrands.Add(productGroupBrand); } db.SaveChanges(); #endregion #region product Group Features var productGroupFeatures = db.ProductGroupFeatures .Where(b => b.ProductGroupId == productGroup.Id).ToList(); // Removing Previous Group Features foreach (var item in productGroupFeatures) { db.ProductGroupFeatures.Remove(item); } db.SaveChanges(); // Adding New Group Features foreach (var featureId in newProductGroup.ProductGroupFeatureIds) { var productGroupFeature = new ProductGroupFeature(); productGroupFeature.ProductGroupId = productGroup.Id; productGroupFeature.FeatureId = featureId; db.ProductGroupFeatures.Add(productGroupFeature); } db.SaveChanges(); #endregion return(productGroup.Id); } return(null); }