public EmpRelativeItem GetById(int id) { Mapper.CreateMap <EmployeeRelative, EmpRelativeItem>(); EmployeeRelative objRelative = DBContext.EmployeeRelatives.SingleOrDefault(m => m.Id == id); EmpRelativeItem objRelativeItem = Mapper.Map <EmpRelativeItem>(objRelative); return(objRelativeItem); }
public int Update(EmpRelativeItem model) { Mapper.CreateMap <EmpRelativeItem, EmployeeRelative>(); EmployeeRelative objRel = DBContext.EmployeeRelatives.SingleOrDefault(m => m.Id == model.Id); objRel = Mapper.Map(model, objRel); return(DBContext.SaveChanges()); }
//For Insert Records in EmployeeRelative table public int Insert(EmpRelativeItem model) { Mapper.CreateMap <EmpRelativeItem, EmployeeRelative>(); EmployeeRelative objRelative = Mapper.Map <EmployeeRelative>(model); DBContext.EmployeeRelatives.Add(objRelative); return(DBContext.SaveChanges()); }
public ActionResult Edit(int id, int RId) { EmpRelativeService objRel = new EmpRelativeService(); EmpRelativeItem objRelItem = new EmpRelativeItem(); objRelItem = objRel.GetById(RId); //Session["Empid"] = objRelItem.EmpId; List <EmpRelativeItem> lstRel = new List <EmpRelativeItem>(); objRelItem.ListRelative = new List <EmpRelativeItem>(); objRelItem.ListRelative.AddRange(lstRel); ViewBag.RId = RId; ViewBag.Menuid = Request.QueryString["menuId"]; return(View(objRelItem)); }
public ActionResult Create() { int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); objRel = new EmpRelativeService(); List <EmpRelativeItem> listRel = new List <EmpRelativeItem>(); listRel = objRel.RelativeListData(Empid); ViewBag.Empid = Empid; EmpRelativeItem objRelitem = new EmpRelativeItem(); objRelitem.ListRelative = new List <EmpRelativeItem>(); objRelitem.ListRelative.AddRange(listRel); ViewBag.Menuid = Request.QueryString["menuId"]; return(View(objRelitem)); }
public ActionResult delete(int id, int cid, int menuid) { //int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); EmpRelativeService objService = new EmpRelativeService(); List <EmpRelativeItem> lstItem = new List <EmpRelativeItem>(); EmpRelativeItem objDoc = new EmpRelativeItem(); objDoc = objService.GetById(cid); db.EmployeeRelatives.Remove(db.EmployeeRelatives.Find(cid)); db.SaveChanges(); //ViewBag.Empid = Empid; ViewBag.Menuid = Request.QueryString["menuId"]; return(RedirectToAction("Create", new { @id = id, @menuId = Request.QueryString["menuId"] })); }
public ActionResult Create(EmpRelativeItem model) { model.Status = "Active"; int Empid = Convert.ToInt32(Url.RequestContext.RouteData.Values["id"].ToString()); model.EmpId = Empid; string uid = null; if (Session["UserId"] != null) { uid = Session["UserId"].ToString(); } model.CreatedBy = uid; model.CreatedDate = System.DateTime.Now; objRel = new EmpRelativeService(); objRel.Insert(model); return(RedirectToAction("Create", new { @menuId = model.Viewbagidformenu })); }