Пример #1
0
 public EditModel(IGuidGenerator guidGenerator, IJsonSerializer jsonSerializer, TimesheetAppService timesheetAppService, EmployeeAppService employeeAppService, IRepository <DictionaryValue, Guid> dicValuesRepo, IRepository <TimesheetWeekSummary, int> timesheetWeekSummaryRepo, IRepository <TimesheetWeekJobSummary, int> timesheetWeekJobSummaryRepo)
 {
     this.guidGenerator          = guidGenerator;
     JsonSerializer              = jsonSerializer;
     TimesheetAppService         = timesheetAppService;
     EmployeeAppService          = employeeAppService;
     DicValuesRepo               = dicValuesRepo;
     TimesheetWeekSummaryRepo    = timesheetWeekSummaryRepo;
     TimesheetWeekJobSummaryRepo = timesheetWeekJobSummaryRepo;
 }
Пример #2
0
        //public List<Employee_Dto> GetEmployees()
        //{
        //    return EmployeeAppService.GetAllEmployees();
        //}

        public IActionResult OnGetWeeksheet(SearchVM searchVM)
        {
            CurrentWeeksheet = TimesheetAppService.GetWeekSummary(searchVM.Year, searchVM.Month, searchVM.Week, searchVM.EmployeeId);
            if (CurrentWeeksheet == null)
            {
                CurrentWeeksheet = new TimesheetWeekSummary_Dto()
                {
                    Id                 = -1,
                    Year               = searchVM.Year,
                    Month              = searchVM.Month,
                    Week               = searchVM.Week,
                    EmployeeId         = searchVM.EmployeeId,
                    WeeklyJobSummaries = new List <TimesheetWeekJobSummary_Dto>()
                };
            }
            return(PartialView("_Weeksheet", this));
        }
Пример #3
0
        public void OnGet()
        {
            List <Timesheet_Dto> timesheets = TimesheetAppService.GetTimesheetsSummary();

            ViewData["Timesheets_DS"]      = JsonSerializer.Serialize(timesheets);
            ViewData["Timesheets_ChildDS"] = JsonSerializer.Serialize(timesheets.SelectMany(x => x.WeeklySummaries).ToList());

            GetSecondaryGrid = new Grid()
            {
                DataSource    = ViewData["Timesheets_ChildDS"],
                QueryCellInfo = "secQueryCellInfo",
                Load          = "onLoad",
                QueryString   = "timesheetId",
                EditSettings  = new Syncfusion.EJ2.Grids.GridEditSettings()
                {
                },
                AllowExcelExport   = true,
                AllowPdfExport     = true,
                HierarchyPrintMode = HierarchyGridPrintMode.All,
                AllowSelection     = true,
                AllowFiltering     = false,
                AllowSorting       = true,
                AllowMultiSorting  = true,
                AllowResizing      = true,
                GridLines          = GridLine.Both,
                SearchSettings     = new GridSearchSettings()
                {
                },
                //Toolbar = new List<object>() { "ExcelExport", "CsvExport", "Print", "Search",new { text = "Copy", tooltipText = "Copy", prefixIcon = "e-copy", id = "copy" }, new { text = "Copy With Header", tooltipText = "Copy With Header", prefixIcon = "e-copy", id = "copyHeader" } },
                ContextMenuItems = new List <object>()
                {
                    "AutoFit", "AutoFitAll", "SortAscending", "SortDescending", "Copy", "Edit", "Delete", "Save", "Cancel", "PdfExport", "ExcelExport", "CsvExport", "FirstPage", "PrevPage", "LastPage", "NextPage"
                },
                Columns = GetSecondaryGridColumns()
            };
        }
Пример #4
0
 public ListModel(IGuidGenerator guidGenerator, IJsonSerializer jsonSerializer, TimesheetAppService timesheetAppService)
 {
     this.guidGenerator  = guidGenerator;
     JsonSerializer      = jsonSerializer;
     TimesheetAppService = timesheetAppService;
 }
Пример #5
0
        public async Task <IActionResult> OnPostSaveTimesheet(TimesheetWeekSummary_Dto weeksheetDto)
        {
            try
            {
                if (TimesheetAppService.Repository.Any(x => x.EmployeeId == weeksheetDto.EmployeeId && x.Year == weeksheetDto.Year && x.Month == weeksheetDto.Month))
                {
                    Timesheet timesheetToUpdate;
                    if (weeksheetDto.Id == -1)
                    {
                        timesheetToUpdate = TimesheetAppService.Repository.WithDetails().First(x => x.EmployeeId == weeksheetDto.EmployeeId && x.Year == weeksheetDto.Year && x.Month == weeksheetDto.Month);

                        weeksheetDto.Id = 0;
                        TimesheetWeekSummary weeksheetToAdd = ObjectMapper.Map <TimesheetWeekSummary_Dto, TimesheetWeekSummary>(weeksheetDto);
                        timesheetToUpdate.WeeklySummaries.Add(weeksheetToAdd);

                        var updated = await TimesheetAppService.Repository.UpdateAsync(timesheetToUpdate);
                    }
                    else
                    {
                        TimesheetWeekSummary weeksheetToUpdate = TimesheetWeekSummaryRepo.WithDetails(x => x.WeeklyJobSummaries).First(x => x.Id == weeksheetDto.Id);
                        weeksheetToUpdate.SumSun         = weeksheetDto.SumSun;
                        weeksheetToUpdate.SumMon         = weeksheetDto.SumMon;
                        weeksheetToUpdate.SumTue         = weeksheetDto.SumTue;
                        weeksheetToUpdate.SumWed         = weeksheetDto.SumWed;
                        weeksheetToUpdate.SumThu         = weeksheetDto.SumThu;
                        weeksheetToUpdate.SumFri         = weeksheetDto.SumFri;
                        weeksheetToUpdate.SumSat         = weeksheetDto.SumSat;
                        weeksheetToUpdate.TotalWeekHours = weeksheetDto.TotalWeekHours;

                        List <TimesheetWeekJobSummary> newJobSumaries = ObjectMapper.Map <ICollection <TimesheetWeekJobSummary_Dto>, List <TimesheetWeekJobSummary> >(weeksheetDto.WeeklyJobSummaries);
                        for (int i = 0; i < newJobSumaries.Count; i++)
                        {
                            if (!weeksheetToUpdate.WeeklyJobSummaries.Any(x => x.Id == newJobSumaries[i].Id))
                            {
                                weeksheetToUpdate.WeeklyJobSummaries.Add(newJobSumaries[i]);
                            }
                            else
                            {
                                TimesheetWeekJobSummary timesheetWeekJobSummary = newJobSumaries[i];
                                var jobSummary = weeksheetToUpdate.WeeklyJobSummaries.First(x => x.Id == timesheetWeekJobSummary.Id);
                                jobSummary.ChargeabilityId    = timesheetWeekJobSummary.ChargeabilityId;
                                jobSummary.ServiceLineId      = timesheetWeekJobSummary.ServiceLineId;
                                jobSummary.ClientId           = timesheetWeekJobSummary.ClientId;
                                jobSummary.Sun                = timesheetWeekJobSummary.Sun;
                                jobSummary.Mon                = timesheetWeekJobSummary.Mon;
                                jobSummary.Tue                = timesheetWeekJobSummary.Tue;
                                jobSummary.Wed                = timesheetWeekJobSummary.Wed;
                                jobSummary.Thu                = timesheetWeekJobSummary.Thu;
                                jobSummary.Fri                = timesheetWeekJobSummary.Fri;
                                jobSummary.Sat                = timesheetWeekJobSummary.Sat;
                                jobSummary.TotalJobWeekHours  = timesheetWeekJobSummary.TotalJobWeekHours;
                                jobSummary.IsSubmitted        = timesheetWeekJobSummary.IsSubmitted;
                                weeksheetToUpdate.IsSubmitted = timesheetWeekJobSummary.IsSubmitted;
                                weeksheetToUpdate.Description = weeksheetDto.Description;
                                jobSummary.IsDeleted          = timesheetWeekJobSummary.IsDeleted;
                                var updated = await TimesheetWeekJobSummaryRepo.UpdateAsync(jobSummary);
                            }
                            await TimesheetWeekSummaryRepo.UpdateAsync(weeksheetToUpdate);
                        }
                    }

                    timesheetToUpdate            = TimesheetAppService.Repository.WithDetails().First(x => x.EmployeeId == weeksheetDto.EmployeeId && x.Year == weeksheetDto.Year && x.Month == weeksheetDto.Month);
                    timesheetToUpdate.Week1Hours = timesheetToUpdate.WeeklySummaries.Where(x => x.Week == 1 && x.IsSubmitted).Sum(x => x.TotalWeekHours);
                    timesheetToUpdate.Week2Hours = timesheetToUpdate.WeeklySummaries.Where(x => x.Week == 2 && x.IsSubmitted).Sum(x => x.TotalWeekHours);
                    timesheetToUpdate.Week3Hours = timesheetToUpdate.WeeklySummaries.Where(x => x.Week == 3 && x.IsSubmitted).Sum(x => x.TotalWeekHours);
                    timesheetToUpdate.Week4Hours = timesheetToUpdate.WeeklySummaries.Where(x => x.Week == 4 && x.IsSubmitted).Sum(x => x.TotalWeekHours);
                    timesheetToUpdate.Week5Hours = timesheetToUpdate.WeeklySummaries.Where(x => x.Week == 5 && x.IsSubmitted).Sum(x => x.TotalWeekHours);

                    timesheetToUpdate.TotalMonthHours = timesheetToUpdate.Week1Hours + timesheetToUpdate.Week2Hours + timesheetToUpdate.Week3Hours + timesheetToUpdate.Week4Hours + timesheetToUpdate.Week5Hours;
                    await TimesheetAppService.Repository.UpdateAsync(timesheetToUpdate);
                }
                else
                {
                    Timesheet_Dto timesheetToCreateDto = new Timesheet_Dto();
                    timesheetToCreateDto.Year       = weeksheetDto.Year;
                    timesheetToCreateDto.Month      = weeksheetDto.Month;
                    timesheetToCreateDto.EmployeeId = weeksheetDto.EmployeeId;
                    weeksheetDto.Id    = 0;
                    weeksheetDto.Dated = DateTime.Now;
                    timesheetToCreateDto.WeeklySummaries = new List <TimesheetWeekSummary_Dto>()
                    {
                        weeksheetDto
                    };
                    timesheetToCreateDto.Dated = DateTime.Now;

                    switch (weeksheetDto.Week)
                    {
                    case 1:
                        timesheetToCreateDto.Week1Hours = weeksheetDto.TotalWeekHours;
                        break;

                    case 2:
                        timesheetToCreateDto.Week2Hours = weeksheetDto.TotalWeekHours;
                        break;

                    case 3:
                        timesheetToCreateDto.Week3Hours = weeksheetDto.TotalWeekHours;
                        break;

                    case 4:
                        timesheetToCreateDto.Week4Hours = weeksheetDto.TotalWeekHours;
                        break;

                    case 5:
                        timesheetToCreateDto.Week5Hours = weeksheetDto.TotalWeekHours;
                        break;
                    }
                    timesheetToCreateDto.TotalMonthHours = timesheetToCreateDto.Week1Hours + timesheetToCreateDto.Week2Hours + timesheetToCreateDto.Week3Hours + timesheetToCreateDto.Week4Hours + timesheetToCreateDto.Week5Hours;

                    Timesheet_Dto timesheetCreatedDto = await TimesheetAppService.CreateAsync(timesheetToCreateDto);
                }
            }
            catch (Exception ex)
            {
                return(StatusCode(500));
            }

            return(new OkResult());
        }
Пример #6
0
 public ListModel(IJsonSerializer jsonSerializer, PayrunAppService payrunAppService, IRepository <PayrunDetail, int> payrunDetailsRepo, CompanyAppService CompanyAppService, EmployeeAppService employeeAppService, IRepository <DictionaryValue, Guid> dicValuesRepo, documentAppService documentAppService, TimesheetAppService timesheetAppService, IWebHostEnvironment webHostEnvironment)
 {
     JsonSerializer           = jsonSerializer;
     PayrunAppService         = payrunAppService;
     PayrunDetailsRepo        = payrunDetailsRepo;
     CompanyAppService        = CompanyAppService;
     EmployeeAppService       = employeeAppService;
     DicValuesRepo            = dicValuesRepo;
     this.documentAppService  = documentAppService;
     this.timesheetAppService = timesheetAppService;
     this.webHostEnvironment  = webHostEnvironment;
 }