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); }
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; }