public CartModel CreateCart(CartModel cartModel) { _context = new karrykartEntities(); Cart userCart = new Cart() { ID = Guid.NewGuid(), CartUserID = cartModel.User == Guid.Empty?Guid.NewGuid():cartModel.User }; _context.Carts.Add(userCart); _context.SaveChanges(); _context.CartProducts.Add(new CartProduct() { CartID = userCart.ID, ProductID = cartModel.ProductID, Quantity = cartModel.Quantity }); _context.SaveChanges(); cartModel.CartID = userCart.ID; cartModel.ProductCount = userCart.CartProducts.Sum(x => x.Quantity).Value; cartModel.User = userCart.CartUserID.Value; cartModel.UserName = string.IsNullOrEmpty(cartModel.UserName)?"Guest":cartModel.UserName; _context = null; return(cartModel); }
public CartModel DeleteCart(Guid CartID, Guid ProductID) { _context = new karrykartEntities(); var cart = _context.Carts.Find(CartID); if (cart != null) { var products = cart.CartProducts.Where(x => x.ProductID == ProductID).FirstOrDefault(); if (products != null) { _context.Entry(products).State = System.Data.Entity.EntityState.Deleted; } _context.SaveChanges(); if (cart.CartProducts.Count == 0) { _context.Entry(cart).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); return(null); } return(new CartModel() { CartID = CartID }); } return(null); }
public ActionResult Edit(SliderModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var slide = _dbContext.Sliders.Find(model.SliderID); if (slide != null) { slide.Active = model.Active; slide.Name = model.Name; slide.Offer = model.OfferText; slide.OfferHeading = model.OfferHeading; slide.ImageLink = model.Image.ContentLength > 0 ?CommonHelper.UploadFile(model.Image, _sliderDirectory):model.Imagelink; _dbContext.Entry(slide).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The image has been edited successfully,Slider ID= " + model.SliderID, "Edit", "SliderController", User.Identity.Name); Success("The image has been edited successfully, with ID = " + slide.SliderID, true); } else { } } } return(View()); }
public ActionResult AddStockPrice(ProductStockPriceModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var productSizeMapping = new ProductSizeMapping() { ProductID = model.ProductID, SizeID = model.SizeID, UnitID = model.UnitID, Stock = model.Stock }; _dbContext.ProductSizeMappings.Add(productSizeMapping); var productprice = new ProductPrice() { UnitID = model.UnitID, CurrencyID = model.CurrencyID, ProductID = model.ProductID, SizeID = model.SizeID, Price = Convert.ToDecimal(model.Price) }; _dbContext.ProductPrices.Add(productprice); var productShipping = new ProductShipping() { UnitID = model.UnitID, ProductID = model.ProductID, SizeID = model.SizeID, Cost = Convert.ToDecimal(model.ShippingCost) }; _dbContext.ProductShippings.Add(productShipping); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product Stock and price added successfully with ID=" + model.Name, "AddStockPrice", "ProductController", User.Identity.Name); return(RedirectToAction("Index", "Product")); } } CreateViewBagForStockPrice(); return(View()); }
public ActionResult EditBasicProductDetails(ProductDetailsModel model) { if (model.ProductID != Guid.Empty) { _dbContext = new karrykartEntities(); var product = _dbContext.Products.Find(model.ProductID); if (product != null) { product.Active = model.Active; product.BrandID = model.BrandID; product.CategoryID = model.CategoryID; product.SubCategoryID = model.SubCategoryID; product.Description = model.Description; product.Name = model.Name; product.UpdatedBy = User.Identity.Name; product.UpdatedOn = DateTime.Now; _dbContext.Entry(product).State = EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Basic product details updated successfully with Name=" + model.Name, "EditBasicProductDetails", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "Basic product details updated successfully." })); } } return(View()); }
public void WriteLog(string messageType, string message, string methodName, string fileName, string userName) { var log = new Log(){ EventTimeStamp = DateTime.UtcNow, FileName = fileName, IpAddress = GetIPAddress(), Message = message, MessageType = messageType, MethodName = methodName, UserName = userName, Browser = HttpContext.Current.Request.UserAgent}; try { _dbContext = new karrykartEntities(); _dbContext.Logs.Add(log); _dbContext.SaveChanges(); } catch (Exception ex) { } finally { _dbContext = null; } }
public ActionResult DeleteProductSizeMapping(Guid ProductID, int SizeID) { if (ProductID != null) { _dbContext = new karrykartEntities(); var productSizeMapping = _dbContext.ProductSizeMappings.Where(x => x.ProductID == ProductID && x.SizeID == SizeID).FirstOrDefault(); _dbContext.Entry(productSizeMapping).State = EntityState.Deleted; var productPrice = _dbContext.ProductPrices.Where(x => x.ProductID == ProductID && x.SizeID == SizeID).FirstOrDefault(); _dbContext.Entry(productPrice).State = EntityState.Deleted; var productSC = _dbContext.ProductShippings.Where(x => x.ProductID == ProductID && x.SizeID == SizeID).FirstOrDefault(); _dbContext.Entry(productSC).State = EntityState.Deleted; _dbContext.SaveChanges(); _dbContext = null; _logger.WriteLog(CommonHelper.MessageType.Success, "Product stock, price and size mapping details has been deleted successfully.", "DeleteProductSizeMapping", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "Product stock, price and size mapping details has been deleted successfully." })); } return(View()); }
public ActionResult Edit(SliderModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var slide = _dbContext.Sliders.Find(model.SliderID); if (slide != null) { slide.Active = model.Active; slide.Name = model.Name; slide.Offer = model.OfferText; slide.OfferHeading = model.OfferHeading; slide.ImageLink = model.Image.ContentLength > 0 ?CommonHelper.UploadFile(model.Image,_sliderDirectory):model.Imagelink; _dbContext.Entry(slide).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The image has been edited successfully,Slider ID= " + model.SliderID, "Edit", "SliderController", User.Identity.Name); Success("The image has been edited successfully, with ID = " + slide.SliderID, true); } else { } } } return View(); }
public ActionResult AddImageFeatureDetails(ProductModel model) { using (_dbContext = new karrykartEntities()) { if (!(String.IsNullOrEmpty(model.Features))) { foreach (var featureText in model.Features.Split(';')) { _dbContext.ProductFeatures.Add(new ProductFeature() { Feature = featureText, ProductID = model.ProductID }); } } var lstImages = UploadImage(model); foreach (var image in lstImages) { if (!String.IsNullOrEmpty(image)) { _dbContext.ProductImages.Add(new ProductImage() {ImageID=Guid.NewGuid(), ImageLink = image, ProductID = model.ProductID }); _dbContext.SaveChanges(); } } _logger.WriteLog(CommonHelper.MessageType.Success, "Product imgaes and features added successfully with name=" + model.ProductID, "Create", "ProductController", User.Identity.Name); return RedirectToAction("AddStockPrice", "Product", new { id = model.ProductID }); } return View(model); }
public void WriteLog(string messageType, string message, string methodName, string fileName, string userName) { var log = new Log() { EventTimeStamp = DateTime.UtcNow, FileName = fileName, IpAddress = GetIPAddress(), Message = message, MessageType = messageType, MethodName = methodName, UserName = userName, Browser = HttpContext.Current.Request.UserAgent }; try { _dbContext = new karrykartEntities(); _dbContext.Logs.Add(log); _dbContext.SaveChanges(); } catch (Exception ex) { } finally { _dbContext = null; } }
public ActionResult Create(ProductModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var product = new Product() { Active = model.Active, CategoryID = model.CategoryID, CreatedBy = User.Identity.Name, UpdatedBy = User.Identity.Name, Description = model.Description, Name = model.Name, ProductID = Guid.NewGuid(), SubCategoryID = model.SubCategoryID, BrandID = model.BrandID, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now }; _dbContext.Products.Add(product); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product created successfully with name=" + product.ProductID, "Create", "ProductController", User.Identity.Name); return(RedirectToAction("AddImageFeatureDetails", "Product", new { id = product.ProductID })); } } CreateViewBagForProduct(); return(View()); }
public UserInformation LoginUser(UserModel model) { var userInfo = new UserInformation(); if (ValidateUser(model)) { using (_context = new karrykartEntities()) { var user = _context.Users.Where(x => x.EmailAddress == model.user).FirstOrDefault(); if (user.UserLogins.Count == 0) { var userLogin = new UserLogin() { LoginTime = DateTime.Now, Token = Guid.NewGuid(), TokenExpiry = DateTime.Now.AddDays(15), UserID = user.UserID }; _context.UserLogins.Add(userLogin); _context.SaveChanges(); userInfo.ExpiryDateTime = userLogin.TokenExpiry.Value; userInfo.Token = userLogin.Token.Value; userInfo.UserID = userLogin.UserID.Value; userInfo.Name = model.user;//(user.UserDetails != null) ? user.UserDetails.FirstOrDefault().FirstName : model.user; } } } else { userInfo.Error = "invalid_user"; } return(userInfo); }
public ActionResult AddImageFeatureDetails(ProductModel model) { using (_dbContext = new karrykartEntities()) { if (!(String.IsNullOrEmpty(model.Features))) { foreach (var featureText in model.Features.Split(';')) { _dbContext.ProductFeatures.Add(new ProductFeature() { Feature = featureText, ProductID = model.ProductID }); } } var lstImages = UploadImage(model); foreach (var image in lstImages) { if (!String.IsNullOrEmpty(image)) { _dbContext.ProductImages.Add(new ProductImage() { ImageID = Guid.NewGuid(), ImageLink = image, ProductID = model.ProductID }); _dbContext.SaveChanges(); } } _logger.WriteLog(CommonHelper.MessageType.Success, "Product imgaes and features added successfully with name=" + model.ProductID, "Create", "ProductController", User.Identity.Name); return(RedirectToAction("AddStockPrice", "Product", new { id = model.ProductID })); } return(View(model)); }
public CartModel UpdateCart(CartModel cartModel) { _context = new karrykartEntities(); var cart = _context.Carts.Find(cartModel.CartID); if (cart != null) { var product = cart.CartProducts.Where(x => x.ProductID == cartModel.ProductID).FirstOrDefault(); if (product != null) { if (cartModel.IsQuantityUpdate) { product.Quantity = cartModel.Quantity; } else { product.Quantity = product.Quantity + 1; } _context.Entry(product).State = System.Data.Entity.EntityState.Modified; } else { _context.CartProducts.Add(new CartProduct() { CartID = cart.ID, ProductID = cartModel.ProductID, Quantity = cartModel.Quantity }); } _context.SaveChanges(); cartModel.ProductCount = cart.CartProducts.Sum(x => x.Quantity).Value; } return(cartModel); }
public ActionResult AddProductStockPrice(Guid ProductID, int SizeID, string SizeName, int UnitID, int SizeTypeID, int Stock, decimal Cost, decimal Price) { if (ProductID != null) { _dbContext = new karrykartEntities(); var productSizeMapping = _dbContext.ProductSizeMappings.Where(x => x.ProductID == ProductID && x.SizeID == SizeID && x.UnitID == UnitID).FirstOrDefault(); if (productSizeMapping == null) { productSizeMapping = new ProductSizeMapping(); productSizeMapping.ProductID = ProductID; productSizeMapping.SizeID = SizeID; productSizeMapping.Stock = Stock; productSizeMapping.UnitID = UnitID; _dbContext.Entry(productSizeMapping).State = EntityState.Added; } else { return(Json(new { messagetype = ApplicationMessages.Product.ERROR, message = "Product and size mapping details already exists." })); } var price = _dbContext.ProductPrices.Where(x => x.ProductID == ProductID && x.SizeID == SizeID && x.UnitID == UnitID).FirstOrDefault(); if (price == null) { price = new ProductPrice(); price.Price = Price; price.SizeID = SizeID; price.ProductID = ProductID; price.CurrencyID = 1; price.UnitID = UnitID; _dbContext.Entry(price).State = EntityState.Added; } else { return(Json(new { messagetype = ApplicationMessages.Product.ERROR, message = "Product's size and Price mapping details already exists." })); } var shipping = _dbContext.ProductShippings.Where(x => x.SizeID == SizeID && x.ProductID == ProductID && x.UnitID == UnitID).FirstOrDefault(); if (shipping == null) { shipping = new ProductShipping(); shipping.Cost = Cost; shipping.SizeID = SizeID; shipping.ProductID = ProductID; shipping.UnitID = UnitID; _dbContext.Entry(shipping).State = EntityState.Added; } else { return(Json(new { messagetype = ApplicationMessages.Product.ERROR, message = "Product size and shipping cost mapping details already exists." })); } _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product stock, price and size mapping details has been added successfully.", "EditProductStockPrice", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "Product stock, price and size mapping details has been added successfully." })); } return(View()); }
public static void SaveOTP(string otp, string assignedTo) { var dbContext = new karrykartEntities(); dbContext.OTPHolders.Add(new OTPHolder() { OTPValue = otp, OTPAssignedTo = assignedTo }); dbContext.SaveChanges(); dbContext = null; }
public static void RemoveOTP(string assignedTo) { var dbContext = new karrykartEntities(); var otp = dbContext.OTPHolders.Where(x => x.OTPAssignedTo == assignedTo).FirstOrDefault(); if (otp != null) { dbContext.Entry(otp).State = EntityState.Deleted; dbContext.SaveChanges(); } dbContext = null; }
public bool Logout(Guid UserID, Guid token) { using (_context = new karrykartEntities()) { var userLoginEntry = _context.UserLogins.Where(l => l.Token == token && l.UserID == UserID).FirstOrDefault(); if (userLoginEntry != null) { _context.Entry(userLoginEntry).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); return(true); } } return(false); }
public ActionResult Create(CountryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { _dbContext.Countries.Add(new Country() { CountryName = model.Name }); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "New country successfully with Name=" + model.Name, "Create", "CountryController", User.Identity.Name); Success("A new country is added successfully.", true); return RedirectToAction("Index", "Country"); } } return View(); }
public UserDetails RemoveUserAddress(Guid Id, int AddressID = -1) { using (_context = new karrykartEntities()) { var userAddress = _context.UserAddressDetails.Where(x => x.UserID == Id && x.AddressID == AddressID).FirstOrDefault(); if (userAddress != null) { _context.Entry(userAddress).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); } } return(GetUser(Id)); }
public bool ChangePassword(UserSignUpModel userModel) { using (_context = new karrykartEntities()) { var user = _context.Users.Where(u => u.EmailAddress == userModel.user).FirstOrDefault(); if (user != null) { user.Password = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(userModel.pwd)); user.LastUpdated = DateTime.Now; _context.Entry(user).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(true); } return(false); } }
public ActionResult RemoveProductImage(Guid ProductID, Guid ImageID) { if (ProductID != null) { _dbContext = new karrykartEntities(); var productImage = _dbContext.ProductImages.Where(x => x.ProductID == ProductID && x.ImageID == ImageID).FirstOrDefault(); _dbContext.Entry(productImage).State = EntityState.Deleted; _dbContext.SaveChanges(); _dbContext = null; _logger.WriteLog(CommonHelper.MessageType.Success, "Product image deleted successfully.", "RemoveProductImage", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "New product feature details added successfully." })); } return(View()); }
public ActionResult AddNewProductImage(Guid ProductID, HttpPostedFileBase file) { if (file != null) { _dbContext = new karrykartEntities(); var productImage = new ProductImage() { ImageID = Guid.NewGuid(), ImageLink = CommonHelper.UploadFile(file, _productImages), ProductID = ProductID }; _dbContext.ProductImages.Add(productImage); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product image added successfully for product ID=" + ProductID + ", ImageID=" + productImage.ImageID, "AddNewProductImage", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "New product image details added successfully.", id = productImage.ImageID, ImageLink = productImage.ImageLink })); } return(View()); }
public ActionResult Create(BrandModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var brand = new Brand(); brand.Name = model.Name; _dbContext.Brands.Add(brand); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Brand add successfully with id=" + brand.BrandID, "Create", "BrandController", User.Identity.Name); Success("The brand is added successfully.", true); return(RedirectToAction("Index", "Brand")); } } return(View()); }
public ActionResult EditProductFeature(Guid ProductID, int FeatureID, string featureText) { _dbContext = new karrykartEntities(); var feature = _dbContext.ProductFeatures.Where(f => f.FeatureID == FeatureID && f.ProductID == ProductID).FirstOrDefault(); if (feature != null) { feature.Feature = featureText; _dbContext.Entry(feature).State = EntityState.Modified; _dbContext.SaveChanges(); _dbContext = null; _logger.WriteLog(CommonHelper.MessageType.Success, "Product feature edited successfully with id=" + FeatureID, "EditProductFeature", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "Product feature added successfully." })); } return(View()); }
public ActionResult RemoveProductFeature(Guid ProductID, int FeatureID) { _dbContext = new karrykartEntities(); var feature = _dbContext.ProductFeatures.Where(x => x.FeatureID == FeatureID && x.ProductID == ProductID).FirstOrDefault(); if (feature != null) { _dbContext.Entry(feature).State = EntityState.Deleted; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product feature deleted successfully with id=" + FeatureID, "RemoveProductFeature", "ProductController", User.Identity.Name); _dbContext = null; return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "Product feature removed successfully." })); } return(View()); }
public ActionResult Edit(BrandModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var brand = _dbContext.Brands.Find(model.BrandID); brand.Name = model.Name; _dbContext.Entry(brand).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The brand is edited successfully with id=" + brand.BrandID, "Edit", "BrandController", User.Identity.Name); Success("The brand is edit successfully.", true); return(RedirectToAction("Index", "Brand")); } } return(View(model)); }
public ActionResult Edit(CategoryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var category = _dbContext.Categories.Find(model.CategoryID); category.Name = model.Name; _dbContext.Entry(category).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The category has been edited successfully,category ID= " + model.CategoryID, "Edit", "CategoryController", User.Identity.Name); Success("The category has been edited successfully.", true); return(RedirectToAction("Index", "Category")); } } return(View()); }
public ActionResult Create(CategoryModel model) { if (ModelState.IsValid) { var category = new Category(); category.Name = model.Name; using (_dbContext = new karrykartEntities()) { _dbContext.Categories.Add(category); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Category created successfully with categoryID=" + category.CategoryID, "Create", "CategoryController", User.Identity.Name); Success("Category is created successfully.", true); return(RedirectToAction("Index", "Category")); } } return(View()); }
public ActionResult Edit(BrandModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var brand = _dbContext.Brands.Find(model.BrandID); brand.Name = model.Name; _dbContext.Entry(brand).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The brand is edited successfully with id=" + brand.BrandID, "Edit", "BrandController", User.Identity.Name); Success("The brand is edit successfully.", true); return RedirectToAction("Index", "Brand"); } } return View(model); }
public ActionResult Create(BrandModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var brand = new Brand(); brand.Name = model.Name; _dbContext.Brands.Add(brand); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Brand add successfully with id=" + brand.BrandID, "Create", "BrandController", User.Identity.Name); Success("The brand is added successfully.", true); return RedirectToAction("Index", "Brand"); } } return View(); }
public bool UpdateUser(UserModel model) { if (model != null) { _context = new karrykartEntities(); var userAddr = _context.UserAddressDetails.Where(s => s.UserID == model.UserID).FirstOrDefault(); if (userAddr != null) { userAddr.AddressLine1 = model.AddressLine1; userAddr.AddressLine2 = model.AddressLine2; userAddr.CityID = model.CityID; userAddr.StateID = model.StateID; userAddr.CountryID = model.CountryID; userAddr.Landmark = model.Landmark; userAddr.Pincode = model.Pincode; } var userDetails = _context.UserDetails.Where(x => x.UserID == model.UserID).FirstOrDefault(); if (userDetails != null) { userDetails.FirstName = model.FirstName; userDetails.LastName = model.LastName; userDetails.Salutation = model.Salutation; } var user = _context.Users.Find(model.UserID); if (user != null) { user.Mobile = model.Mobile; user.ProfileComplete = true; user.LastUpdated = DateTime.Now; } _context.Entry(userDetails).State = System.Data.Entity.EntityState.Modified; _context.Entry(userAddr).State = System.Data.Entity.EntityState.Modified; _context.Entry(user).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(true); } return(false); }
public ActionResult CreateUnit(UnitModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { _dbContext.Units.Add(new Unit() { Name = model.Name }); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Unit created successfully with Name=" + model.Name, "CreateUnit", "ProductSettingsController", User.Identity.Name); Success("A new unit is created successfully.", true); return(RedirectToAction("UnitDetails", "ProductSettings")); } } return(View()); }
public ActionResult Create(CategoryModel model) { if (ModelState.IsValid) { var category = new Category(); category.Name = model.Name; using (_dbContext = new karrykartEntities()) { _dbContext.Categories.Add(category); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Category created successfully with categoryID=" + category.CategoryID, "Create", "CategoryController", User.Identity.Name); Success("Category is created successfully.", true); return RedirectToAction("Index", "Category"); } } return View(); }
public ActionResult Create(CountryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { _dbContext.Countries.Add(new Country() { CountryName = model.Name }); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "New country successfully with Name=" + model.Name, "Create", "CountryController", User.Identity.Name); Success("A new country is added successfully.", true); return(RedirectToAction("Index", "Country")); } } return(View()); }
public ActionResult AddProductFeature(Guid ProductID, int FeatureID, string featureText) { if (FeatureID == -1) { _dbContext = new karrykartEntities(); var feature = new ProductFeature() { ProductID = ProductID, Feature = featureText }; _dbContext.ProductFeatures.Add(feature); _dbContext.SaveChanges(); _dbContext = null; _logger.WriteLog(CommonHelper.MessageType.Success, "Product feature added successfully with text=" + featureText, "AddProductFeature", "ProductController", User.Identity.Name); return(Json(new { messagetype = ApplicationMessages.Product.SUCCESS, message = "New product feature details added successfully.", id = feature.FeatureID })); } return(View()); }
public ActionResult CreateCurrency(CurrencyModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { _dbContext.Currencies.Add(new Currency() { CountryID = model.CountryID, Name = model.CurrencyName, Shortform = model.ShortName }); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Currency created successfully with Name=" + model.CurrencyName, "CreateUnit", "ProductSettingsController", User.Identity.Name); Success("A new currency is created successfully.", true); return(RedirectToAction("CurrencyDetails", "ProductSettings")); } } CreateViewbagForCurrency(model.CountryID); return(View(model)); }
public ActionResult Createsubcategory(SubcategoryModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var Subcategory = new Subcategory(); Subcategory.CategoryID = model.CategoryID; Subcategory.Name = model.Name; _dbContext.Subcategories.Add(Subcategory); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success,"New sub category added successfully with id="+Subcategory.SCategoryID,"CreateSubcategory","CategoryController",User.Identity.Name); Success("Subcategory added successfully"); return RedirectToAction("Subcategory", "Category", new { id = model.CategoryID }); } } return View(model); }
public ActionResult Edit(CategoryModel model) { if (ModelState.IsValid) { using (_dbContext =new karrykartEntities()) { var category = _dbContext.Categories.Find(model.CategoryID); category.Name = model.Name; _dbContext.Entry(category).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The category has been edited successfully,category ID= " + model.CategoryID, "Edit", "CategoryController", User.Identity.Name); Success("The category has been edited successfully.", true); return RedirectToAction("Index", "Category"); } } return View(); }
public ActionResult Create(ProductModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var product = new Product() { Active = model.Active, CategoryID = model.CategoryID, CreatedBy = User.Identity.Name, UpdatedBy = User.Identity.Name, Description = model.Description, Name = model.Name, ProductID = Guid.NewGuid(), SubCategoryID = model.SubCategoryID, BrandID = model.BrandID, CreatedOn = DateTime.Now, UpdatedOn = DateTime.Now }; _dbContext.Products.Add(product); _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Product created successfully with name=" + product.ProductID, "Create", "ProductController", User.Identity.Name); return RedirectToAction("AddImageFeatureDetails", "Product", new { id = product.ProductID }); } } CreateViewBagForProduct(); return View(); }