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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 bool VerifyOtp(OtpModel model) { _context = new karrykartEntities(); var otp = _context.OTPHolders.Where(x => x.OTPAssignedTo == model.UserIdentifier && x.OTPValue == model.Userotp).FirstOrDefault(); if (otp != null) { var user = _context.Users.Where(u => u.EmailAddress == model.UserIdentifier || u.Mobile == model.UserIdentifier).FirstOrDefault(); user.LastUpdated = DateTime.Now; user.Active = true; _context.Entry(user).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); CommonHelper.RemoveOTP(model.UserIdentifier); return(SendOtpVerificationToUser(user)); } return(false); }
public bool SetPassword(LoginModel model) { _context = new karrykartEntities(); var user = _context.Users.Where(x => x.EmailAddress == model.UserID).FirstOrDefault(); if (user != null) { user.Password = EncryptionManager.ConvertToUnSecureString(EncryptionManager.EncryptData(model.UserPwd)); _context.Entry(user).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } _context = null; _emailHelper = new EmailHelper(); var IsMessageSent = SendChangePasswordMessage(model.UserID); _emailHelper = null; return(IsMessageSent); }
public ActionResult EditUnit(UnitModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var unit = _dbContext.Units.Find(model.UnitID); if (unit != null) { unit.Name = model.Name; _dbContext.Entry(unit).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "The unit has been edited successfully,unit ID= " + model.UnitID, "EditUnit", "ProductSettingsController", User.Identity.Name); Success("The unit has been edited successfully.", true); return(RedirectToAction("UnitDetails", "ProductSettings")); } } } return(View()); }
public UserInformation CheckLogin(UserInformation user) { using (_context = new karrykartEntities()) { var userLogin = _context.UserLogins.Where(ul => ul.UserID == user.UserID && ul.Token == user.Token).FirstOrDefault(); if (userLogin != null) { if ((user.ExpiryDateTime - userLogin.TokenExpiry.Value).Days <= 15) { userLogin.TokenExpiry = DateTime.Now.AddDays(15); _context.Entry(userLogin).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); user.ExpiryDateTime = userLogin.TokenExpiry.Value; } else { user.Error = "token_expired"; } } } return(user); }
public ActionResult EditCurrency(CurrencyModel model) { if (ModelState.IsValid) { using (_dbContext = new karrykartEntities()) { var currency = _dbContext.Currencies.Find(model.CurrencyID); if (currency != null) { currency.Name = model.CountryName; currency.CountryID = model.CountryID; currency.Shortform = model.ShortName; _dbContext.Entry(currency).State = System.Data.Entity.EntityState.Modified; _dbContext.SaveChanges(); _logger.WriteLog(CommonHelper.MessageType.Success, "Currency edited successfully with Name=" + model.CurrencyName, "CreateUnit", "ProductSettingsController", User.Identity.Name); Success("A currency is edited successfully.", true); return(RedirectToAction("CurrencyDetails", "ProductSettings")); } } } CreateViewbagForCurrency(model.CountryID); return(View(model)); }
public CartModel DeleteCart(Guid CartID) { _context = new karrykartEntities(); var cart = _context.Carts.Find(CartID); if (cart != null) { // var products = cart.CartProducts.Where(x => x.CartID == CartID); // if (products != null) // { //// foreach (var p in products) // // { // _context.Entry(products).State = System.Data.Entity.EntityState.Deleted; //// } // } _context.Entry(cart).State = System.Data.Entity.EntityState.Deleted; _context.SaveChanges(); return(new CartModel()); } return(null); }
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 UserDetails EditUserAddress(AddUserAddressModel user) { using (_context = new karrykartEntities()) { if (!user.GuestCheckout) { var usr = _context.Users.Find(user.UserID); if (usr != null) { if (string.IsNullOrEmpty(usr.EmailAddress)) { usr.EmailAddress = user.Email; } usr.Mobile = user.Phone; usr.LastUpdated = DateTime.UtcNow; usr.ProfileComplete = true; _context.Entry(usr).State = System.Data.Entity.EntityState.Modified; } var userDetails = _context.UserDetails.Where(x => x.UserID == user.UserID).FirstOrDefault(); if (userDetails != null) { if (string.IsNullOrEmpty(userDetails.FirstName)) { userDetails.FirstName = user.FirstName; userDetails.LastName = user.LastName; _context.Entry(userDetails).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } var userAddress = _context.UserAddressDetails.Where(x => x.UserID == user.UserID && x.AddressID == user.AddressID).FirstOrDefault(); if (userAddress != null) { userAddress.AddressLine1 = user.AddressLine1; userAddress.AddressLine2 = user.AddressLine2; userAddress.CityID = user.CityID; userAddress.StateID = user.StateID; userAddress.CountryID = user.CountryID; userAddress.Landmark = user.LandMark; userAddress.Pincode = user.PinCode; _context.Entry(userAddress).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); } } else { var guestUser = _context.GuestUserDetails.Find(user.UserID); if (guestUser != null) { guestUser.AddressLine1 = user.AddressLine1; guestUser.AddressLine2 = user.AddressLine2; guestUser.CityID = user.CityID; guestUser.CountryID = user.CountryID; guestUser.EmailAddress = user.Email; guestUser.FirstName = user.FirstName; guestUser.LandMark = user.LandMark; guestUser.LastName = user.LastName; guestUser.Phone = user.Phone; guestUser.Pincode = user.PinCode; guestUser.StateID = user.StateID; _context.Entry(guestUser).State = System.Data.Entity.EntityState.Modified; _context.SaveChanges(); return(GetGuestUserDetails(guestUser.ID)); } } } return(GetUser(user.UserID)); }