Пример #1
0
        public async Task <List <extension.Activities> > GetActivities(ActivityRequest req, int selfId)
        {
            //TODO: Проект убрать после отладки
            var workItems = await _azureDevOpsService.GetChildWorkItems(req.Project ?? "ShtormDemoProject(Agile)", selfId);

            int[] wiIds      = workItems.Select(x => x.Id).Where(x => x != null).Cast <int>().ToArray();
            var   timesheets = await _timesheetRepository.GetTimesheets(wiIds);

            return(timesheets.GroupingActivitiesDuration().ToList());
        }
Пример #2
0
        public IActionResult List(DateTime startDate, DateTime endDate)
        {
            var timesheets = _timesheetRepository.GetTimesheets(GetUserId(), startDate.Date, endDate.Date);
            var result     = new[]
            {
                new UserTimesheetListResponse
                {
                    Timesheets = _mapper.Map <TimesheetResponse[]>(timesheets)
                }
            };

            CalculateFlexTime(result);
            return(Ok(result));
        }
Пример #3
0
        private List <string> RetrieveProjectsWithTimesheets()
        {
            List <string>           projects   = new List <string>();
            IEnumerable <Timesheet> timesheets = _timeSheetRepository.GetTimesheets().Where(r => r.Status.ToString().Equals("Approved"))
                                                 .OrderByDescending(r => r.WeekStarting);

            foreach (Timesheet ts in timesheets)
            {
                foreach (TimesheetEntry tse in ts.TimesheetEntries)
                {
                    if (!projects.Contains(tse.Code))
                    {
                        projects.Add(tse.Code);
                    }
                }
            }

            return(projects);
        }
        public async Task <ActionResult <List <Timesheet> > > GetTimesheets(string WorkItemIds = "", string UserId = "", bool isDeleted = false)
        {
            int[] wids = null;

            if (WorkItemIds != "")
            {
                try
                {
                    wids = WorkItemIds.Split(',').Select(s => int.Parse(s)).ToArray();
                }
                catch (FormatException)
                {
                    return(BadRequest("Массив \"WorkItemIds\" не распознан. Небоходимый формат \"workItemids=1,2,3\" "));
                }
            }
            return(await _timesheetRepository.GetTimesheets(wids, UserId, isDeleted));
        }
Пример #5
0
        public IEnumerable <TimesheetDto> Get()
        {
            List <TimesheetDto> timesheetsDtos = new List <TimesheetDto>();

            IEnumerable <Timesheet> timesheets = _timeSheetRepository.GetTimesheets().OrderByDescending(r => r.WeekStarting);

            foreach (Timesheet ts in timesheets)
            {
                timesheetsDtos.Add(ConvertToDto(ts));
            }
            return(timesheetsDtos);
        }
Пример #6
0
        public ProjectCostDto DetermineProjectCosts(string code)
        {
            ProjectCostDto costs = new ProjectCostDto();

            costs.ProjectName = code;

            ApprovedTimesheetForProject approvedTimesheetSpecification = new ApprovedTimesheetForProject(code);

            IEnumerable <Timesheet> timesheets = _repository.GetTimesheets();

            foreach (Timesheet ts in timesheets.AsQueryable())
            {
                if (approvedTimesheetSpecification.IsSatisfied(ts))
                {
                    double rate = _repository.GetRateForTimesheet(ts);

                    if (!costs.weekAlreadyRecorded(ts.WeekStarting.ToShortDateString()))
                    {
                        costs.addWeek(ts.WeekStarting.ToShortDateString());
                        costs.addCost(ts.CalculateHoursWorkedForProject(code) * (decimal)rate);
                    }
                    else
                    {
                        //Need to find the index in the ICollection to update costs for a given week.
                        int     index         = costs.Weeks.IndexOf(ts.WeekStarting.ToShortDateString());
                        decimal existingCosts = costs.Costs.ElementAt(index);
                        existingCosts += ts.CalculateHoursWorkedForProject(code) * (decimal)rate;
                        //Need to update value at a specific index.
                        costs.Costs.RemoveAt(index);
                        costs.Costs.Insert(index, existingCosts);
                    }
                }
            }

            return(costs);
        }
Пример #7
0
 public IEnumerable <Timesheet> GetTimesheets()
 {
     return(timesheetRepository.GetTimesheets());
 }
        public async Task <IActionResult> GetAllTimesheets()
        {
            var timesheets = await timesheetRepo.GetTimesheets();

            return(Ok(timesheets.Select(t => mapper.Map <TimesheetViewModel>(t))));
        }
Пример #9
0
 public IEnumerable <Timesheet> Get(string id)
 {
     return(_timesheetRepository.GetTimesheets(Guid.Parse(id)));
 }