Esempio n. 1
0
 public void GetAuthoritiesList()
 {
     try
     {
         GetAuthoritiesListResponse response = _userService.GetAuthoritiesList(new GetAuthoritiesListRequest());
         Assert.IsTrue(response.IsSucess && response.Authorities != null && response.Authorities.Count > 0);
     }
     catch (Exception ex)
     {
         Assert.IsTrue(false);
     }
 }
Esempio n. 2
0
        public GetAuthoritiesListResponse GetAuthoritiesList(GetAuthoritiesListRequest request)
        {
            GetAuthoritiesListResponse response = new GetAuthoritiesListResponse();

            try
            {
                using (IUnitOfWork unitOfWork = RepositoryFactory.GetUnitOfWork())
                {
                    if (request != null)
                    {
                        IAuthorityRepository authorityRepository = RepositoryFactory.Get(typeof(IAuthorityRepository), unitOfWork) as IAuthorityRepository;
                        List <Authority>     authorities         = authorityRepository.GetAll().ToList();
                        unitOfWork.Commit();
                        if (authorities != null)
                        {
                            foreach (var item in authorities)
                            {
                                ViewModels.AuthorityView node = new ViewModels.AuthorityView()
                                {
                                    Id = item.Id, Name = item.Name
                                };
                                if (response.Authorities == null)
                                {
                                    response.Authorities = new List <ViewModels.AuthorityView>();
                                }
                                response.Authorities.Add(node);
                            }
                            response.IsSucess = true;
                        }
                        else
                        {
                            response.IsSucess = false;
                            response.Message  = "No Authority!";
                        }
                    }
                    else
                    {
                        response.IsSucess = false;
                        response.Message  = "No Input!";
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(ex.Message);
                response.IsSucess = false;
                response.Message  = ex.Message;
            }
            return(response);
        }