Example #1
0
        public static UsersViewModel MToVM(User user)
        {
            var temp = new UsersViewModel()
            {
                ID            = user.ID,
                Code          = Comparison.IsNullOrEmpty(user.Code) ? "" : user.Code,
                LastName      = Comparison.IsNullOrEmpty(user.LastName) ? "" : user.LastName,
                MiddleName    = Comparison.IsNullOrEmpty(user.MiddleName) ? "" : user.MiddleName,
                FirstName     = Comparison.IsNullOrEmpty(user.FirstName) ? "" : user.FirstName,
                ExtensionName = Comparison.IsNullOrEmpty(user.ExtensionName) ? "" : user.ExtensionName,
                Gender        = Comparison.IsNullOrEmpty(user.Gender) ? "N/A" : user.Gender,
                MaritalStatus = Comparison.IsNullOrEmpty(user.MaritalStatus) ? "N/A" : user.MaritalStatus,
                Nationality   = Comparison.IsNullOrEmpty(user.Nationality) ? "N/A" : user.Nationality,
                Religion      = Comparison.IsNullOrEmpty(user.Religion) ? "N/A" : user.Religion,
                Address       = Comparison.IsNullOrEmpty(user.Address) ? "N/A" : user.Address,
                Birthday      = TimeFormatter.DateToString(user.Birthday.Value),
                Jobtitle      = JobTitleUtility.MToVM(user.JobTitle),
                Email         = Comparison.IsNullOrEmpty(user.Email) ? "N/A" : user.Email,
                ContactPerson = Comparison.IsNullOrEmpty(user.ContactPerson) ? "N/A" : user.ContactPerson,
                ContactNumber = Comparison.IsNullOrEmpty(user.ContactNumber) ? "N/A" : user.ContactNumber,
                profileImage  = Comparison.IsNullOrEmpty(user.ProfileImage) ? "/Assets/images/no-image.jpg" : user.ProfileImage,
                Company       = CompanyUtility.MToVM(user.Company),
                aspNetUser    = MToVM(user.AspNetUser),
                Department    = DataVerification.IsNull(user.Department) ? new DepartmentViewModel()
                {
                    Name = "N/A"
                } : DepartmentUtility.MToVM(user.Department),
                JobStatus = JobStatusUtility.MToVM(user.JobStatu),
                User      = AspNetUserUtility.MToVM(user.AspNetUser),
                TimeZone  = user.TimeZone
            };

            return(temp);
        }
        public static UserAttendanceVM MToVM(Attendance item)
        {
            var temp = new UserAttendanceVM()
            {
                id                = item.ID,
                profileImage      = item.User.ProfileImage == null ? "/Assets/images/no-image.jpg" : item.User.ProfileImage,
                name              = item.User.FirstName + " " + item.User.LastName + " " + item.User.ExtensionName,
                actualLoginImage  = item.TimeInImage == null ? "/Assets/images/no-image.jpg" : item.TimeInImage,
                actualLoginTime   = item.TimeIn.HasValue ? item.TimeIn.Value.Hours + ":" + item.TimeIn.Value.Minutes : "not yet",
                actualLogoutImage = item.TimeOutImage == null ? "/Assets/images/no-image.jpg" : item.TimeOutImage,
                actualLogoutTime  = item.TimeOut != null ? item.TimeOut.Value.Hours + ":" + item.TimeOut.Value.Minutes : "not yet",
                TotalWorkHours    = item.HrsWork.HasValue ? item.HrsWork.Value.ToString() : "N/A",
                TotalBreakTime    = item.TotalBreakTime.HasValue ? item.TotalBreakTime.Value.ToString() : "N/A",
                ProductiveHours   = item.ProductiveHrs.HasValue ? item.ProductiveHrs.Value.ToString() : "N/A",
                Remarks           = item.Remarks == "" || item.Remarks == null ? "N/A" : item.Remarks,
                DateCreated       = TimeFormatter.DateToString(item.CreatedAt.Value),
                AttendanceDate    = TimeFormatter.DateToString(item.AttendanceDate.Value),
                User              = new UsersViewModel()
                {
                    ID = item.User.ID, FirstName = item.User.FirstName, LastName = item.User.LastName, MiddleName = item.User.MiddleName, ExtensionName = item.User.ExtensionName
                },
                Shift = new ShiftViewModel()
                {
                    ID = item.ShiftID, TimeIn = item.Shift.TimeIn.HasValue ? item.Shift.TimeIn.Value.ToString() : "00:00:00", TimeOut = item.Shift.TimeOut.HasValue ? item.Shift.TimeOut.Value.ToString() : "00:00:00"
                },
                Status = new AttendanceStatusViewModel()
                {
                    ID = item.AttendanceStatusID
                }
            };

            return(temp);
        }
Example #3
0
        public static CompanyViewModel MToVM(Company model)
        {
            var temp = new CompanyViewModel()
            {
                ID        = model.id,
                Name      = model.name,
                createdAt = model.CreatedAt.HasValue ? TimeFormatter.DateToString(model.CreatedAt.Value) : "N/A",
            };

            return(temp);
        }
Example #4
0
 public static HolidayVM MToVM(Holiday vm)
 {
     return(new HolidayVM()
     {
         ID = vm.ID,
         Description = vm.Description,
         StartDate = vm.StartDate.HasValue ? TimeFormatter.DateToString(vm.StartDate.Value) : "N/A",
         EndDate = vm.EndDate.HasValue ? TimeFormatter.DateToString(vm.EndDate.Value) : "N/A",
         Company = new CompanyViewModel()
         {
             ID = vm.CompanyID
         }
     });
 }