public ActionResult Create(ProductCategory category) { category.rowguid = Guid.NewGuid(); category.ModifiedDate = DateTime.Now; context.ProductCategory.Add(category); context.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Create(ProductModel model) { if (ModelState.IsValid) { model.rowguid = Guid.NewGuid(); model.ModifiedDate = DateTime.Now; context.ProductModel.Add(model); context.SaveChanges(); } return(RedirectToAction("List")); }
public ActionResult Create(ProductSubCategory subcategory, int ProductCategoryID) { var category = context.ProductCategory.Find(ProductCategoryID); subcategory.CategoryName = category.Name; subcategory.ProductCategoryID = ProductCategoryID; subcategory.rowguid = Guid.NewGuid(); subcategory.ModifiedDate = DateTime.Now; context.ProductSubCategory.Add(subcategory); context.SaveChanges(); return(RedirectToAction("List")); }
public ActionResult Create(Product product, int ProductModelId, int ProductCategoryID, int ProductSubCategoryID, HttpPostedFileBase file) { Photo photo = new Photo(); photo.rowguid = Guid.NewGuid(); photo.ModifiedDate = DateTime.Now; product.ProductModelId = ProductModelId; product.ProductSubCategoryID = ProductSubCategoryID; product.rowguid = Guid.NewGuid(); product.ModifiedDate = DateTime.Now; if (ModelState.IsValid) { photo.Name = file.FileName; photo.Image = new byte[file.ContentLength]; file.InputStream.Read(photo.Image, 0, file.ContentLength); context.Photo.Add(photo); context.SaveChanges(); product.PhotoID = photo.PhotoID; context.Product.Add(product); context.SaveChanges(); return(RedirectToAction("Index")); } return(View(product)); }