public IActionResult CreateCheckOut([FromBody] CreateCheckoutDto data)
        {
            //convert the date sent from the client into a DateTime format
            data.ShiftDate = Convert.ToDateTime(data.StringDate).Date;

            try
            {
                UtilityMethods.ValidateLunchOrDinnerSpecification(data.LunchOrDinner);
                StaffMemberDto staffMember = _staffCore.GetStaffMember(data.StaffMemberId);
                JobDto         job         = _jobCore.GetJobByTitle(data.JobWorkedTitle);
                CheckoutDto    checkout    = _checkoutsCore.CreateCheckout(data, staffMember, job);
                return(CreatedAtRoute("CreateCheckout", checkout));
            }
            catch (Exception e)
            {
                if (e.InnerException is InvalidOperationException)
                {
                    return(BadRequest(e.Message));
                }
                _logger.LogError(e.Message);
                ModelState.AddModelError("Create Checkout Failure", e.Message);
                return(StatusCode(500, ModelState));
            }
        }
Exemple #2
0
 public IActionResult GetStaffMember(int staffId)
 {
     try
     {
         if (!_staffCore.StaffMemberExists(staffId))
         {
             return(NotFound());
         }
         return(Ok(_staffCore.GetStaffMember(staffId)));
     }
     catch (Exception e)
     {
         _logger.LogError(e, "An error occured while retrieving a specific staff member");
         return(StatusCode(500, errorMsg));
     }
 }