public ActionResult Create(tbl_ProductCategory tbl_productcategory,HttpPostedFileBase file) { if (ModelState.IsValid) { tbl_productcategory.IsActive = true; tbl_productcategory.CreatedBy = User.Identity.Name; tbl_productcategory.CreatedDate = DateTime.Now; if (file != null) { file.SaveAs(HttpContext.Server.MapPath("~/Images/ProductCategory/") + file.FileName); tbl_productcategory.ImagePath = "Images/ProductCategory/" + file.FileName; } db.tbl_ProductCategory.AddObject(tbl_productcategory); //Audit db.tbl_AuditTrail.AddObject(new tbl_AuditTrail { Action = "CREATE", ActionItem = "ProductCategory", UserName = User.Identity.Name, ActionDate = DateTime.Now }); db.SaveChanges(); return RedirectToAction("Index"); } return View(tbl_productcategory); }
/// <summary> /// Deprecated Method for adding a new object to the tbl_ProductCategory EntitySet. Consider using the .Add method of the associated ObjectSet<T> property instead. /// </summary> public void AddTotbl_ProductCategory(tbl_ProductCategory tbl_ProductCategory) { base.AddObject("tbl_ProductCategory", tbl_ProductCategory); }
/// <summary> /// Create a new tbl_ProductCategory object. /// </summary> /// <param name="category_Id">Initial value of the Category_Id property.</param> /// <param name="category_Name">Initial value of the Category_Name 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_ProductCategory Createtbl_ProductCategory(global::System.Int32 category_Id, global::System.String category_Name, global::System.String createdBy, global::System.DateTime createdDate) { tbl_ProductCategory tbl_ProductCategory = new tbl_ProductCategory(); tbl_ProductCategory.Category_Id = category_Id; tbl_ProductCategory.Category_Name = category_Name; tbl_ProductCategory.CreatedBy = createdBy; tbl_ProductCategory.CreatedDate = createdDate; return tbl_ProductCategory; }