public ActionResult Create(tbl_ProductDetails tbl_productdetails, HttpPostedFileBase file) { if (ModelState.IsValid) { tbl_productdetails.CreatedBy = User.Identity.Name; tbl_productdetails.CreatedDate = DateTime.Now; tbl_productdetails.ModifiedBy = User.Identity.Name; tbl_productdetails.ModifiedDate = DateTime.Now; tbl_productdetails.ImageModifiedDate = DateTime.Now; tbl_productdetails.IsActive = true; if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Images/Product/") + file.FileName); tbl_productdetails.ImagePath = "Images/Product/" + file.FileName; } db.tbl_ProductDetails.AddObject(tbl_productdetails); //Audit db.tbl_AuditTrail.AddObject(new tbl_AuditTrail { Action="CREATE", ActionItem="Product", UserName = User.Identity.Name, ActionDate=DateTime.Now }); db.SaveChanges(); return RedirectToAction("Index"); } ViewBag.Category_Id = new SelectList(db.tbl_ProductCategory, "Category_Id", "Category_Name", tbl_productdetails.Category_Id); return View(tbl_productdetails); }
/// <summary> /// Deprecated Method for adding a new object to the tbl_ProductDetails EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotbl_ProductDetails(tbl_ProductDetails tbl_ProductDetails) { base.AddObject("tbl_ProductDetails", tbl_ProductDetails); }
/// <summary> /// Create a new tbl_ProductDetails object. /// </summary> /// <param name="product_Id">Initial value of the Product_Id property.</param> /// <param name="isActive">Initial value of the IsActive property.</param> /// <param name="createdBy">Initial value of the CreatedBy property.</param> /// <param name="createdDate">Initial value of the CreatedDate property.</param> public static tbl_ProductDetails Createtbl_ProductDetails(global::System.Int32 product_Id, global::System.Boolean isActive, global::System.String createdBy, global::System.DateTime createdDate) { tbl_ProductDetails tbl_ProductDetails = new tbl_ProductDetails(); tbl_ProductDetails.Product_Id = product_Id; tbl_ProductDetails.IsActive = isActive; tbl_ProductDetails.CreatedBy = createdBy; tbl_ProductDetails.CreatedDate = createdDate; return tbl_ProductDetails; }