Пример #1
0
        public async Task <IActionResult> Put([FromBody] LoadData load)
        {
            try
            {
                if (!_userContext.UserId.HasValue)
                {
                    throw new Exception("Invalid UserId");
                }

                if (await this._userProfileService.IsViewOnlyUserAsync(_userContext.UserId.Value))
                {
                    return(Error <LoadData>(new ValidationException("You currently have view only access to Loadshop and cannot book loads at this time.")));
                }

                try
                {
                    return(Success(_loadService.PendingAcceptLoad(load, _userContext.UserId.Value)));
                }
                catch (ValidationException valEx)
                {
                    return(Error <LoadData>(valEx));
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            catch (UnauthorizedAccessException ex)
            {
                return(Forbidden <ResponseMessage <LoadData> >(ex));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }