public List<LeaveViewModel> LeaveIndex()
        {
            var listofleave = entity.tblLeaveRecords.ToList();
            List<LeaveViewModel> LeavelistfromModel = new List<LeaveViewModel>();
            foreach(var leaveitem in listofleave)
            {
                LeaveViewModel modelObj = new LeaveViewModel()
                {
                    leaveId=leaveitem.leaveId,
                    leavefrom=leaveitem.leavefrom,
                    leaveuntil=leaveitem.leaveuntil,
                    approverId=leaveitem.approverId,
                    Reason=leaveitem.reason,
                    statusId=leaveitem.statusid,
                    Approver=leaveitem.tblApprover.approverName,
                    Status=leaveitem.tblReqeuestStatu.statusName,
                    employeeId=leaveitem.employeeId,
                    EmployeeName=leaveitem.tblEmployeesInside.EmployeeName,
                    rejectionReason=leaveitem.rejectionreason
                };
                LeavelistfromModel.Add(modelObj);
            }
            return LeavelistfromModel;

        }
 public ActionResult Create(LeaveViewModel leaveModelobj)
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     
         // TODO: Add insert logic here
         leaveRepo.addLeaveRecords(leaveModelobj);
         return RedirectToAction("Index");
     
     
 }
 //
 // GET: /Leave/Create
 public ActionResult Create()
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     
     LeaveViewModel leaveModel = new LeaveViewModel();
     leaveModel.StatusList = dropRepo.StatusDropDown();
     leaveModel.ApproverList = dropRepo.ApproverDropDown();
     leaveModel.EmployeeList = dropRepo.EmployeesDrop();
     return View(leaveModel);
 }
 public void addLeaveRecords(LeaveViewModel leavemodel)
 {
     tblLeaveRecord newLeaveRecord = new tblLeaveRecord()
     {
         leaveId=leavemodel.leaveId,
         approverId=leavemodel.approverId,
         reason=leavemodel.Reason,
         leavefrom=leavemodel.leavefrom,
         leaveuntil=leavemodel.leaveuntil,
         statusid=leavemodel.statusId,
         employeeId=leavemodel.employeeId,
         rejectionreason=leavemodel.rejectionReason
     };
     entity.tblLeaveRecords.Add(newLeaveRecord);
     entity.SaveChanges();
 }
        public LeaveViewModel LeaveDetails(int leaveid)
        {
            var singleLeaveRecord = entity.tblLeaveRecords.Where(x => x.leaveId == leaveid).FirstOrDefault();
            LeaveViewModel Model = new LeaveViewModel()
            {
                leaveId=singleLeaveRecord.leaveId,
                approverId=singleLeaveRecord.approverId,
                statusId=singleLeaveRecord.statusid,
                employeeId=singleLeaveRecord.employeeId,
                EmployeeName=singleLeaveRecord.tblEmployeesInside.EmployeeName,
                Status=singleLeaveRecord.tblReqeuestStatu.statusName,
                leavefrom=singleLeaveRecord.leavefrom,
                leaveuntil=singleLeaveRecord.leaveuntil,
                Reason=singleLeaveRecord.reason

            };
            return Model;
        }
 public ActionResult Edit(int id, LeaveViewModel modelObj)
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     // TODO: Add update logic here
         
         leaveRepo.EditLeaveRecord(modelObj);
         return RedirectToAction("LeaveManagement","Leave");
     
    
 }
 public ActionResult NormalUserLeave(LeaveViewModel leaveModelobj)
 {
     if (HttpContext.Session["UserId"] == null)
     {
         return RedirectToAction("Login", "Login");
     }
     
     leaveRepo.addLeaveRecords(leaveModelobj);
     return RedirectToAction("Index");
     
 }