Ejemplo n.º 1
0
        public Result <UserDto> Fetch(string username)
        {
            Result <UserDto> retResult = Result <UserDto> .Undefined(null);

            try
            {
                DalHelper.CheckAuthorizationMustRunOnServer();

                //Common.CommonHelper.CheckAuthentication();

                var userDto = FetchImpl(username);
                if (userDto == null)
                {
                    throw new Exceptions.UsernameNotFoundException(username);
                }
                retResult = Result <UserDto> .Success(userDto);
            }
            catch (Exception ex)
            {
                var wrapperEx = new Exceptions.GetUserFailedException(ex, username);
                retResult = Result <UserDto> .FailureWithInfo(null, wrapperEx);
            }

            return(retResult);
        }
Ejemplo n.º 2
0
        public Result <UserDto> Delete(Guid id)
        {
            Result <UserDto> retResult = Result <UserDto> .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToDeleteUser();

                var dto = DeleteImpl(id);
                retResult = Result <UserDto> .Success(dto);
            }
            catch (Exception ex)
            {
                var wrappedEx = new Exceptions.DeleteFailedException(ex);
                retResult = Result <UserDto> .FailureWithInfo(null, wrappedEx);
            }
            return(retResult);
        }
Ejemplo n.º 3
0
        public Result <UserDto> New(object criteria)
        {
            Result <UserDto> retResult = Result <UserDto> .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToAddUser();

                var dto = NewImpl(criteria);
                retResult = Result <UserDto> .Success(dto);
            }
            catch (Exception ex)
            {
                var wrappedEx = new Exceptions.CreateFailedException(ex);
                retResult = Result <UserDto> .FailureWithInfo(null, wrappedEx);
            }
            return(retResult);
        }
Ejemplo n.º 4
0
        public Result <UserDto> Insert(UserDto dto)
        {
            Result <UserDto> retResult = Result <UserDto> .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToAddUser();

                var insertedDto = InsertImpl(dto);
                retResult = Result <UserDto> .Success(insertedDto);
            }
            catch (Exception ex)
            {
                var wrappedEx = new Exceptions.InsertFailedException(ex);
                retResult = Result <UserDto> .FailureWithInfo(null, wrappedEx);
            }
            return(retResult);
        }
Ejemplo n.º 5
0
        public Result <ICollection <RoleDto> > GetRoles(string username)
        {
            Result <ICollection <RoleDto> > retResult = Result <ICollection <RoleDto> > .Undefined(null);

            try
            {
                //Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationMustRunOnServer();

                var roles = GetRolesImpl(username);
                retResult = Result <ICollection <RoleDto> > .Success(roles);
            }
            catch (Exception ex)
            {
                var wrappedEx = new Exceptions.GetRolesFailedException(ex, username);
                retResult = Result <ICollection <RoleDto> > .FailureWithInfo(null, wrappedEx);
            }

            return(retResult);
        }
Ejemplo n.º 6
0
        public Result <ICollection <UserDto> > GetAll()
        {
            Result <ICollection <UserDto> > retResult = Result <ICollection <UserDto> > .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToGetAllUsers();

                var allUsers = GetAllImpl();
                retResult = Result <ICollection <UserDto> > .Success(allUsers);
            }
            catch (Exception ex)
            {
                var wrappedEx = new Exceptions.GetAllFailedException(ex);
                retResult = Result <ICollection <UserDto> > .FailureWithInfo(null, wrappedEx);
            }

            return(retResult);
        }
Ejemplo n.º 7
0
        public Result <bool?> Delete(string username)
        {
            Result <bool?> retResult = Result <bool?> .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToDeleteUser();
                var deleteResult = DeleteImpl(username);
                if (deleteResult == null)
                {
                    throw new Exception();
                }
                retResult = Result <bool?> .Success(deleteResult);
            }
            catch (Exception ex)
            {
                var wrapperEx = new Exceptions.GetUserFailedException(ex, username);
                retResult = Result <bool?> .FailureWithInfo(null, wrapperEx);
            }

            return(retResult);
        }
Ejemplo n.º 8
0
        public Result <UserDto> AddUser(Csla.Security.UsernameCriteria criteria)
        {
            Result <UserDto> retResult = Result <UserDto> .Undefined(null);

            try
            {
                Common.CommonHelper.CheckAuthentication();
                DalHelper.CheckAuthorizationToAddUser();

                var userDto = AddUserImpl(criteria);
                if (userDto == null)
                {
                    throw new Exception();
                }
                retResult = Result <UserDto> .Success(userDto);
            }
            catch (Exception ex)
            {
                var wrapperEx = new Exceptions.AddUserFailedException(ex, criteria.Username);
                retResult = Result <UserDto> .FailureWithInfo(null, wrapperEx);
            }

            return(retResult);
        }