예제 #1
0
        public IActionResult CloseShift([FromBody] CloseShiftCommand closeShift)
        {
            if (closeShift.UserId < 0)
            {
                return(BadRequest());
            }
            var    audience   = User.Claims.FirstOrDefault(c => c.Type == "aud").Value;
            var    user       = User.Claims.FirstOrDefault(c => c.Type == "user").Value;
            string storeEmail = audience;
            string posUser    = user;
            int    posUserId  = closeShift.UserId;
            int    shiftId    = closeShift.ShiftId;
            bool   isShift    = _shiftService.IsShiftAvailable(storeEmail, posUserId, shiftId);

            if (!isShift)
            {
                return(BadRequest());
            }

            bool closeShiftStatus = _shiftService.CloseShift(storeEmail, posUserId, shiftId);

            if (!closeShiftStatus)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError));
            }

            return(Ok());
        }