Пример #1
0
 public IList <LeaveTransactionDetail> GetTransactionLog(string Name, string RequestMenuUser, long userId)
 {
     using (var dac = new LeaveTransactionHistoryDac())
     {
         return(dac.GetTransactionLog(Name, RequestMenuUser, userId));
     }
 }
Пример #2
0
        public EmpShift GetEmployeeShiftDetails(Int64 UserId, string RequestMenuUser, long LeaduserId)
        {
            EmpShift retModel = new EmpShift();

            try
            {
                using (var context = new NLTDDbContext())
                {
                    EmployeeDac employeeDac = new EmployeeDac();
                    long        userId = 0; string EmpId = "";
                    string      Name = "";

                    if (RequestMenuUser != "My")
                    {
                        var empPrf = context.Employee
                                     .Where(x => x.UserId == UserId)
                                     .FirstOrDefault();
                        if (empPrf != null)
                        {
                            userId = empPrf.UserId;
                            EmpId  = empPrf.EmployeeId;
                            Name   = empPrf.FirstName + " " + empPrf.LastName;
                        }
                    }
                    else
                    {
                        var empPrf = context.Employee.Where(x => (x.UserId) == LeaduserId).FirstOrDefault();
                        if (empPrf != null)
                        {
                            userId = empPrf.UserId;
                            EmpId  = empPrf.EmployeeId;
                            Name   = empPrf.FirstName + " " + empPrf.LastName;
                        }
                    }

                    if (userId > 0 || (RequestMenuUser == "My" && LeaduserId > 0))
                    {
                        string ReportingTo = (RequestMenuUser == "My" && LeaduserId > 0) ? employeeDac.ReportingToName(LeaduserId) : employeeDac.ReportingToName(userId);

                        string leadRole = employeeDac.GetEmployeeRole(LeaduserId);

                        List <ShiftAllocation> shiftDetails = new List <ShiftAllocation>();
                        if (RequestMenuUser == "My")
                        {
                            shiftDetails = GetShiftDetails(context, LeaduserId);
                        }
                        else if (leadRole == "ADMIN" || leadRole == "HR")
                        {
                            shiftDetails = GetShiftDetails(context, userId);
                        }
                        else if (RequestMenuUser == "Team")
                        {
                            var user = (from e in context.Employee
                                        where e.ReportingToId == LeaduserId
                                        select e).ToList();

                            var found = LeaveTransactionHistoryDac.FindControlRecursively(user, userId);
                            if (found != null)
                            {
                                shiftDetails = GetShiftDetails(context, userId);
                            }
                        }

                        var groupedLeaveList = shiftDetails.GroupBy(u => u.Month)
                                               .Select(grp => new { Month = grp.Key, shiftAllocation = grp.ToList() })
                                               .ToList();

                        List <ShiftDetail> lstshiftDetails = (from gv in groupedLeaveList
                                                              select new ShiftDetail
                        {
                            Month = gv.Month,
                            shiftAllocation = gv.shiftAllocation
                        }).ToList();
                        retModel.shiftDetail = lstshiftDetails;
                        retModel.ReportingTo = ReportingTo;

                        var lstShift = context.ShiftMaster.AsEnumerable().OrderBy(x => x.FromTime).Select(s => new Shifts
                        {
                            ShiftId   = s.ShiftID,
                            ShiftName = string.Format("{0:hh\\:mm}", s.FromTime) + " - " + string.Format("{0:hh\\:mm}", s.ToTime),
                        }).ToList();

                        retModel.Shifts = lstShift;
                    }

                    retModel.Name   = Name;
                    retModel.EmpId  = EmpId;
                    retModel.UserId = userId;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(retModel);
        }