public async Task <ActionResult> EmpSummary()
        {
            var employee = await _userManager.GetUserAsync(User);

            var employeeid = employee.Id;

            //var leaveAllocations = await _leaveAllocRepo.GetLeaveAllocationsByEmployee(employeeid);
            var leaveAllocations = await _unitOfWork.LeaveAllocations.FindAll(q => q.EmployeeId == employeeid, includes : new List <string> {
                "LeaveType"
            });

            var leaveAllocVM = _mapper.Map <List <LeaveAllocationVM> >(leaveAllocations);

            //var leaveRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeid);
            var leaveRequests = await _unitOfWork.LeaveRequests.FindAll(q => q.RequestingEmployeeId == employeeid);

            var leaveRequestVM = _mapper.Map <List <LeaveRequestVM> >(leaveRequests);

            var model = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = leaveAllocVM,
                LeaveRequests    = leaveRequestVM
            };

            return(View(model));
        }
        public async Task <ActionResult> MyLeave()
        {
            try
            {
                var employee = await _userManager.GetUserAsync(User);

                var employeeid          = employee.Id;
                var employeeAllocations = await _repoleaveallocation.GetLeaveAllocationsByEmployee(employeeid);

                var employeeRequests = await _repoleaverequest.GetLeaveRequestsByEmployee(employeeid);

                var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
                var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);
                var model = new EmployeeLeaveRequestVM
                {
                    LeaveAllocations = employeeAllocationsModel,
                    LeaveRequests    = employeeRequestsModel
                };
                return(View(model));
            }
            catch
            {
                return(View());
            }
        }
 /// <summary>
 /// Create Employee Leave Request(Çalışan İzin Talebi oluşturma Methodu)
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public Result <EmployeeLeaveRequestVM> CreateEmployeeLeaveRequest(EmployeeLeaveRequestVM model, SessionContext user)
 {
     if (model != null)
     {
         try
         {
             var leaveRequest = _mapper.Map <EmployeeLeaveRequestVM, EmployeeLeaveRequest>(model);
             leaveRequest.RequestingEmployeeId = user.LoginId;
             leaveRequest.Cancelled            = false;
             leaveRequest.Approved             = (int)EnumEmployeeLeaveRequestStatus.Send_Approved;
             leaveRequest.DateRequested        = DateTime.Now;
             _unitOfWork.employeeLeaveRequestRepository.Add(leaveRequest);
             _unitOfWork.Save();
             return(new Result <EmployeeLeaveRequestVM>(true, ResultConstant.RecordCreateSuccessfully));
         }
         catch (Exception ex)
         {
             return(new Result <EmployeeLeaveRequestVM>(false, ResultConstant.RecordCreateNotSuccessfully + "=>" + ex.Message.ToString()));
         }
     }
     else
     {
         return(new Result <EmployeeLeaveRequestVM>(false, "Parametre Olarak Geçilen Data Boş Olamaz!"));
     }
 }
        public ActionResult MyLeave()
        {
            var employee                 = _userManager.GetUserAsync(User).Result;
            var employeeId               = employee.Id;
            var employeeAllocations      = _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeId);
            var employeeRequests         = _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeId);
            var employeeAllocationsModel = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var employeeRequestsModel    = _mapper.Map <List <LeaveRequestVM> >(employeeRequests);
            var model = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = employeeAllocationsModel,
                LeaveRequests    = employeeRequestsModel
            };

            return(View(model));
        }
        public async Task <ActionResult> MyLeave()
        {
            var employee = await _userManager.GetUserAsync(User);

            var leaveAllocations =
                _mapper.Map <List <LeaveAllocationVM> >(await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employee.Id));
            var leaveRequests =
                _mapper.Map <List <LeaveRequestVM> >(await _leaveRequestRepo.GetLeaveRequestsByEmployee(employee.Id));


            EmployeeLeaveRequestVM model = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = leaveAllocations,
                LeaveRequests    = leaveRequests
            };

            return(View(model));
        }
        public IActionResult Create(EmployeeLeaveRequestVM model, int?id)
        {
            var user = JsonConvert.DeserializeObject <SessionContext>(HttpContext.Session.GetString(ResultConstant.LoginUserInfo));

            #region CreateOrEditExample
            if (id > 0)
            {
                var data = _employeeLeaveRequestBusinessEngine.EditEmployeeLeaveRequest(model, user);
                return(RedirectToAction("Index"));
            }
            else
            {
                var data = _employeeLeaveRequestBusinessEngine.CreateEmployeeLeaveRequest(model, user);
                if (data.IsSuccess)
                {
                    return(RedirectToAction("Index"));
                }
                return(View(model));
            }
            #endregion
        }
Exemplo n.º 7
0
        public async Task <ActionResult> MyLeave()
        {
            var employee = await _userManager.GetUserAsync(User);

            var employeeid = employee.Id;
            //var employeeAllocations = await _leaveAllocationRepo.GetLeaveAllocationsByEmployee(employeeid);
            var employeeAllocations = await _unitOfWork.LeaveAllocations.FindAll(k => k.EmployeeId == employeeid);

            //var employeeLeaveRequests = await _leaveRequestRepo.GetLeaveRequestsByEmployee(employeeid);
            var employeeLeaveRequests = await _unitOfWork.LeaveRequests.FindAll(k => k.RequestingEmployeeId == employeeid);

            var leaveAllocationList = _mapper.Map <List <LeaveAllocationVM> >(employeeAllocations);
            var leaveRequestList    = _mapper.Map <List <LeaveRequestVM> >(employeeLeaveRequests);


            var empObject = new EmployeeLeaveRequestVM
            {
                LeaveAllocations = leaveAllocationList,
                LeaveRequests    = leaveRequestList
            };


            return(View(empObject));
        }