Beispiel #1
0
        public CheckoutPagePresentationDto FormatPageData(List <CheckoutOverviewDto> checkouts, List <ServerTeamDto> serverTeams, List <EarningDto> shiftEarnings, BarTeam barTeam)
        {
            CheckoutPagePresentationDto pageData = new CheckoutPagePresentationDto();

            //Here the teams that have had their checkouts run are assembled into groups for presentation
            foreach (ServerTeamDto s in serverTeams)
            {
                IEnumerable <CheckoutEntity> entities = _repository.GetCheckoutsForATeam(s.Id);
                if (entities.Count() > 0)
                {
                    List <ServerTeamGroupedCheckoutsDto> groupedCheckouts = groupFormatter.FormatServerTeamGroupCheckouts(s, entities, checkouts, serverTeams, shiftEarnings);

                    foreach (ServerTeamGroupedCheckoutsDto t in groupedCheckouts)
                    {
                        pageData.TeamCheckouts.Add(t);
                    }
                }
            }

            //Here is where the distinctions need to be made between bar checkouts, patio,
            //and the server teamed/unrun checkouts
            // *IMPORTANT* - bar checkouts are not saved nor grouped by the teamcheckouts relationship. This is because
            // even though server checkouts can't be grouped by job worked due to the splitting of tips between select people,
            // Bartenders all split up the money based on hours on the same team. So pulling them based on date and job worked
            // is possible because they all go together.
            pageData.BarCheckouts = groupFormatter.FormatBarCheckouts(barTeam, checkouts, shiftEarnings);

            //Now to grab all the checkouts that havent been run and then return the whole dataset
            pageData.NotRunCheckouts = groupFormatter.FormatUnrunServerCheckouts(checkouts, pageData.TeamCheckouts);

            return(pageData);
        }
        public IActionResult GetCheckoutsForShift([FromBody] GetCheckoutsForShiftDto data)
        {
            try
            {
                data.ShiftDate = Convert.ToDateTime(data.StringDate).Date;
                UtilityMethods.ValidateLunchOrDinnerSpecification(data.LunchOrDinner);

                List <CheckoutOverviewDto> checkouts      = _checkoutsCore.GetCheckoutsForShift(data.ShiftDate, data.LunchOrDinner).ToList();
                List <ServerTeamDto>       serverTeams    = _serverTeamCore.GetServerTeamsForShift(data.ShiftDate, data.LunchOrDinner, "Server");
                BarTeam                     barTeam       = _barCore.GetBarTeamForShift(data.ShiftDate, data.LunchOrDinner);
                List <EarningDto>           shiftEarnings = _earningsCore.GetEarningsForShift(data.ShiftDate, data.LunchOrDinner);
                CheckoutPagePresentationDto pageData      = _checkoutsCore.FormatPageData(checkouts, serverTeams, shiftEarnings, barTeam);
                return(Ok(pageData));
            }
            catch (Exception e)
            {
                ModelState.AddModelError("Get Checkouts Error", e.Message);
                if (e is InvalidOperationException)
                {
                    return(BadRequest(ModelState));
                }
                _logger.LogError(e.Message);
                return(StatusCode(500, ModelState));
            }
        }