コード例 #1
0
ファイル: Assistant.cs プロジェクト: sjongberg/OnlineServices
        /*
         *
         * public AssistantRole(IMSUnitOfWork iMSUnitOfWork) : base(iMSUnitOfWork)
         * {
         *  this.iMSUnitOfWork = iMSUnitOfWork ?? throw new System.ArgumentNullException(nameof(iMSUnitOfWork));
         * }
         *
         * */
        public bool AddUser(UserTO userTO)
        {
            if (userTO is null)
            {
                throw new LoggedException(new ArgumentNullException(nameof(userTO)));
            }

            if (userTO.ID != 0)
            {
                throw new Exception("Existing user");
            }

            userTO.Name.IsNullOrWhiteSpace("Missing User Name.");

            try
            {
                userTO.ToDomain();
                iRSUnitOfWork.UserRepository.Add(userTO);

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #2
0
        public bool RemoveUser(UserTO userTO)
        {
            if (userTO is null)
            {
                throw new ArgumentNullException(nameof(userTO));
            }

            if (userTO.Id == 0)
            {
                throw new Exception("User does not exist");
            }

            try
            {
                iRSUnitOfWork.UserRepository.Remove(userTO.ToDomain().ToTransfertObject());

                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        public bool UpdateUser(UserTO userTO)
        {
            if (userTO is null)
            {
                throw new ArgumentNullException((nameof(userTO)));
            }

            if (userTO.Id == 0)
            {
                throw new Exception("User does not exist");
            }

            userTO.Name.IsNullOrWhiteSpace("Missing User Name");

            try
            {
                iRSUnitOfWork.UserRepository.Update(userTO.ToDomain().ToTransfertObject());
                return(true);
            }
            catch (Exception)
            {
                throw;
            }
        }