public ActionResult Create([Bind(Include = "Id,Name,EmailID,Password")] user_master user_master) { if (ModelState.IsValid) { db.user_master.Add(user_master); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(user_master)); }
public ActionResult Create([Bind(Include = "ItemId,CategoryId,ItemCode,ItemName,ShortDescription,LongDescription,SmallImagePath,LongImagePath,ItemPrice")] Item item) { if (ModelState.IsValid) { item.ItemId = Guid.NewGuid(); db.Items.Add(item); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(item)); }
public ActionResult Signup(user_master model) { using (var context = new ProductManagementEntities()) { context.user_master.Add(model); context.SaveChanges(); } return(RedirectToAction("Login")); }
public SupplierVMModel AddAndUpdateSupplier(SupplierVMModel vmModel) { if (vmModel.ID > 0) { var record = _db.Suppliers.Where(x => x.ID == vmModel.ID).FirstOrDefault(); record.Name = vmModel.Name; record.PhoneNumber = vmModel.PhoneNumber; _db.SaveChanges(); } else { Supplier _supplier = new Supplier(); _supplier.Name = vmModel.Name; _supplier.PhoneNumber = vmModel.PhoneNumber; _db.Suppliers.Add(_supplier); _db.SaveChanges(); vmModel.ID = _supplier.ID; } return(vmModel); }
public ProductSupplierVMModel AddAndUpdateProductSupplier(ProductSupplierVMModel vmModel) { if (vmModel.ID > 0) { var record = _db.ProductSuppliers.Where(x => x.ID == vmModel.ID).FirstOrDefault(); record.ProductID = vmModel.ProductID; record.SupplierID = vmModel.SupplierID; _db.SaveChanges(); } else { ProductSupplier _supplier = new ProductSupplier(); _supplier.ProductID = vmModel.ProductID; _supplier.SupplierID = vmModel.SupplierID; _db.ProductSuppliers.Add(_supplier); _db.SaveChanges(); vmModel.ID = _supplier.ID; } return(vmModel); }
public ProductVMModel AddAndUpdateProduct(ProductVMModel vmModel) { if (vmModel.ID > 0) { var record = _db.Products.Where(x => x.ID == vmModel.ID).FirstOrDefault(); record.Name = vmModel.Name; record.Price = vmModel.Price; record.Quantity = vmModel.Quantity; record.Code = vmModel.Code; _db.SaveChanges(); } else { Product _product = new Product(); _product.Name = vmModel.Name; _product.Price = vmModel.Price; _product.Quantity = vmModel.Quantity; _product.Code = vmModel.Code; _db.Products.Add(_product); _db.SaveChanges(); vmModel.ID = _product.ID; } return(vmModel); }
public ActionResult AddProduct(AddProductModel objaddproduct) { string s_fileName = Path.GetFileNameWithoutExtension(objaddproduct.SmallImageFile.FileName); string s_fileExtension = Path.GetExtension(objaddproduct.SmallImageFile.FileName); s_fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + s_fileName.Trim() + s_fileExtension; string s_UploadPath = ConfigurationManager.AppSettings["S_UserImagePath"].ToString(); objaddproduct.SmallImagePath = s_UploadPath + s_fileName; objaddproduct.SmallImageFile.SaveAs(objaddproduct.SmallImagePath); string l_fileName = Path.GetFileNameWithoutExtension(objaddproduct.LongImageFile.FileName); string l_fileExtension = Path.GetExtension(objaddproduct.LongImageFile.FileName); l_fileName = DateTime.Now.ToString("yyyyMMdd") + "-" + l_fileName.Trim() + l_fileExtension; string l_UploadPath = ConfigurationManager.AppSettings["L_UserImagePath"].ToString(); objaddproduct.LongImagePath = l_UploadPath + l_fileName; objaddproduct.LongImageFile.SaveAs(objaddproduct.LongImagePath); Item obItem = new Item(); obItem.CategoryId = Int16.Parse(objaddproduct.Category_Id); obItem.ItemCode = objaddproduct.ItemCode; obItem.ItemName = objaddproduct.ItemName; obItem.ShortDescription = objaddproduct.ShortDescription; obItem.LongDescription = objaddproduct.LongDescription; obItem.ItemPrice = objaddproduct.ItemPrice; obItem.SmallImagePath = objaddproduct.SmallImagePath; obItem.LongImagePath = objaddproduct.LongImagePath; obItem.ItemId = Guid.NewGuid(); dbobj.Items.Add(obItem); dbobj.SaveChanges(); return(View()); }
public IHttpActionResult proinsert(ProductDetail proinsert) { p.ProductDetails.Add(proinsert); p.SaveChanges(); return(Ok()); }
private bool Save() { return(db.SaveChanges() > 0); }