Exemplo n.º 1
0
        public async Task <bool> UpdateCommonUser(UpdateCommonUserRequest request)
        {
            Users oldUser = await _usersCollection.GetAsync(request.UserCode);

            var   copier  = new ClassValueCopier();
            Users newUser = copier.ConvertAndCopy(request, oldUser);

            newUser.LastUpdatedBy = request.CurrentUserCode;
            newUser.LastUpdatedAt = DateTime.Now.ToString();
            return(await _usersCollection.UpdateAsync(newUser));
        }
        public async Task <IActionResult> UpdateCommonUser(UpdateCommonUserRequest request)
        {
            ActionResponse response;

            try
            {
                bool result = await _businessLogic.UpdateCommonUser(request);

                response = (result) ? new ActionResponse(StatusCodes.Status200OK) : new ActionResponse(StatusCodes.Status422UnprocessableEntity);
            }
            catch (Exception ex)
            {
                response = new ActionResponse(StatusCodes.Status500InternalServerError);
                response.StatusDescription += ex.Message.ToString();
            }

            return(StatusCode(response.StatusCode, response));
        }