Exemple #1
0
        public async Task <BusinessResult <bool> > EditAsync(UserDTO entity)
        {
            try
            {
                if (!ValidatePassword(entity.UserPass))
                {
                    throw new UserException(General.InvalidPassword);
                }

                entity.UpdateDate = DatetimeHelper.GetCurrentColombianTime();

                var resultOperation = await _iuserModel.EditAsync(entity);

                return(BusinessResult <bool> .Success(resultOperation, General.OperationSucsess));
            }
            catch (UserException user)
            {
                return(BusinessResult <bool> .Issue(false, user.Message, user));
            }
            catch (GenericADOException ex)
            {
                var sql = ex.InnerException as SqlException;
                if (sql != null && sql.Number == 2627)
                {
                    // Here's where to handle the unique constraint violation
                    return(BusinessResult <bool> .Issue(false, General.UniqueUserName, sql));
                }
                else
                {
                    return(BusinessResult <bool> .Issue(false, General.OperationIssue, sql));
                }
            }
            catch (Exception ex)
            {
                return(BusinessResult <bool> .Issue(false, General.OperationIssue, ex));
            }
        }