public async Task <ActionResult> Edit(EditLeaveAllocationVM model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(View(model));
                }
                var recored = await _leaveallocationrepo.FindById(model.Id);

                recored.NumberOfDays = model.NumberOfDays;

                var isSuccess = await _leaveallocationrepo.update(recored);

                if (!isSuccess)
                {
                    ModelState.AddModelError("", "Error samooooooooooraaaa while saving");
                    return(View(model));
                }
                //just wanted to go back to my recored not show it from the scratch again! instead of index i choosed Details
                //details requiers id so i make a new parameter with the employee id as a value from the edit form
                return(RedirectToAction(nameof(Details), new { id = model.EmployeeId }));
            }
            catch
            {
                return(View(model));
            }
        }
        //my work for index.cshtmll for the buttons
        public async Task <ActionResult> ApproveRequest(int id)
        {
            try
            {
                var user = await _userManager.GetUserAsync(User);

                var leaveRequest = await _leaveRequestRepo.FindById(id);

                var leaveTypeid = leaveRequest.LeaveTypeId;
                var employeeid  = leaveRequest.RequestingEmployeeId;
                var allocation  = await _leaveAllocationRepo.GetLeaveAllocationsByEmployeeAndType(employeeid, leaveTypeid);

                //the NOof days in the alloc is less than requested
                int daysRequested = (int)(leaveRequest.EndDate - leaveRequest.StartDate).TotalDays;
                allocation.NumberOfDays = allocation.NumberOfDays - daysRequested;

                leaveRequest.Approved     = true;
                leaveRequest.ApprovedById = user.Id;
                leaveRequest.DateActioned = DateTime.Now;

                await _leaveRequestRepo.update(leaveRequest);

                await _leaveAllocationRepo.update(allocation);

                return(RedirectToAction(nameof(Index)));
            }
            catch (Exception ex)
            {
                return(RedirectToAction(nameof(Index)));
            }
        }