public ActionResult Register(RegisterViewModel model) { if (ModelState.IsValid) { OnlineMartEntities onlineMartEntities = new OnlineMartEntities(); User user = new User { UserName = model.UserName, Email = model.Email, Password = model.Password, Gender = model.Gender, DateOfBirth = model.DateOfBirth, CityId = model.CityId, StateId = model.StateId, Address = model.Address, Contact = model.Contact }; onlineMartEntities.Users.Add(user); onlineMartEntities.SaveChanges(); return(View("Welcome")); } else { model.States = GetState(); return(View(model)); } }
public int AddProducts(HttpPostedFileBase file, Product productModel) { OnlineMartEntities onlineMartEntities = new OnlineMartEntities(); productModel.Image = ConvertToBytes(file); var Product = new Product { ProductTitle = productModel.ProductTitle, LaunchDate = productModel.LaunchDate, Quantity = productModel.Quantity, Mrp = productModel.Mrp, Discount = productModel.Discount, CategoryId = productModel.CategoryId, Description = productModel.Description, Image = productModel.Image, SellingPrice = productModel.SellingPrice }; onlineMartEntities.Products.Add(Product); int insertedRow = onlineMartEntities.SaveChanges(); if (insertedRow == 1) { return(1); } else { return(0); } }