public ActionResult Create(AssestsItem Model) { AssestsItem objItem = new AssestsItem(); ItemService objItemServ = new ItemService(); string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } Model.CreatedBy = uid; Model.CreatedDate = System.DateTime.Now; Model.Status = "Active"; int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } if (Model.CompID == null) { Model.CompID = cid; } int i = objItemServ.Insert(Model); return(RedirectToAction("Create")); }
public int Insert(AssestsItem model) { Mapper.CreateMap <AssestsItem, Item_Master>(); Item_Master objItem = Mapper.Map <Item_Master>(model); dbContext.Item_Master.Add(objItem); return(dbContext.SaveChanges()); }
public int Update(AssestsItem model) { Item_Master objItem = dbContext.Item_Master.Where(m => m.ItemId == model.ItemId).FirstOrDefault(); objItem.CatId = model.CatId; objItem.ItemName = model.ItemName; objItem.OpStock = model.OpStock; objItem.ItemDesc = model.ItemDesc; objItem.UpdatedBy = model.UpdatedBy; objItem.UpdatedDate = model.UpdatedDate; return(dbContext.SaveChanges()); }
public AssestsItem GetItemsById(int ItemId) { Item_Master objItemMst = dbContext.Item_Master.SingleOrDefault(m => m.ItemId == ItemId); AssestsItem objItem = new AssestsItem(); objItem.ItemName = objItemMst.ItemName; objItem.ItemId = objItemMst.ItemId; objItem.CatId = objItemMst.CatId; objItem.ItemDesc = objItemMst.ItemDesc; objItem.OpStock = objItemMst.OpStock; objItem.Status = objItemMst.Status; return(objItem); }
public ActionResult Edit(AssestsItem Model) { AssestsItem objItem = new AssestsItem(); ItemService objItemServ = new ItemService(); string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } Model.UpdatedBy = uid; Model.UpdatedDate = System.DateTime.Now; int i = objItemServ.Update(Model); return(RedirectToAction("Create")); }
public ActionResult Edit(int ItemId) { CategoryService objCatServ = new CategoryService(); CategoryItem objCatItem = new CategoryItem(); ItemService objItemServ = new ItemService(); AssestsItem objItem = new AssestsItem(); List <AssestsItem> lstItems = new List <AssestsItem>(); objItem = objItemServ.GetItemsById(ItemId); int cid = 0; if (Session["CompID"] != null) { cid = Convert.ToInt32(Session["CompID"].ToString()); } lstItems = objItemServ.GetALLItems(cid); objItem.lstOfItems = new List <AssestsItem>(); objItem.lstOfItems.AddRange(lstItems); List <CategoryItem> lstCat = new List <CategoryItem>(); lstCat = objCatServ.GetALL(cid); objItem.lstCategory = new List <CategoryItem>(); objItem.lstCategory.AddRange(lstCat); SponsorService objService = new SponsorService(); List <CompanyItem> lstCompany = new List <CompanyItem>(); lstCompany = objService.GetCompany(); objItem.ListCompany = new List <CompanyItem>(); objItem.ListCompany.AddRange(lstCompany); VehicleMasterService objVehicle = new VehicleMasterService(); #region Bind DropDown Branch List <BranchItem> lstBranch = new List <BranchItem>(); lstBranch = objVehicle.GetBranch(); objItem.ListBranch = new List <BranchItem>(); objItem.ListBranch.AddRange(lstBranch); #endregion return(View(objItem)); }