Esempio n. 1
0
 /// <summary>
 /// Gets an <see cref="IMacro"/> object by its alias
 /// </summary>
 /// <param name="alias">Alias to retrieve an <see cref="IMacro"/> for</param>
 /// <returns>An <see cref="IMacro"/> object</returns>
 public IMacro GetByAlias(string alias)
 {
     using (var repository = _repositoryFactory.CreateMacroRepository(_uowProvider.GetUnitOfWork()))
     {
         return(repository.Get(alias));
     }
 }
Esempio n. 2
0
        public GroupPageListEntity GetAll(GroupPageEntity entity, long pageIndex, long pageSize)
        {
            var list = new GroupPageListEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var query = PetaPoco.Sql.Builder.Append(@"SELECT * FROM GroupPage");
                    query.Append("ORDER BY ModifiedDate DESC");
                    var result = _uow.Db.Page <GroupPageEntity>(pageIndex, pageSize, query);
                    if (result != null && result.TotalItems > 0)
                    {
                        list.List      = result.Items;                     // danh sách data trả về
                        list.PageTotal = result.TotalPages;                // tổng số Pages
                        list.PageIndex = result.CurrentPage;               // Page hiện tại của data duoc trả về
                        list.Count     = Protector.Int(result.TotalItems); //  count data
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoGroupPage, "GetAll : ", ex.ToString());
            }
            return(list);
        }
 public StudentDto Add(StudentDto entity)
 {
     using (var uow = _uowProvider.GetUnitOfWork())
     {
         var id = uow.Db.Insert(entity);
         uow.Commit();
         entity.Id = Convert.ToInt32(id);
     }
     return(entity);
 }
Esempio n. 4
0
 /// <summary>
 /// Gets a list of all <see cref="Stylesheet"/> objects
 /// </summary>
 /// <returns>An enumerable list of <see cref="Stylesheet"/> objects</returns>
 public IEnumerable <Stylesheet> GetStylesheets(params string[] names)
 {
     using (var repository = _repositoryFactory.CreateStylesheetRepository(_fileUowProvider.GetUnitOfWork()))
     {
         return(repository.GetAll(names));
     }
 }
Esempio n. 5
0
        public List <DepartmentEntity> GetDepartment(bool bActived, int branchId)
        {
            var list = new List <DepartmentEntity>();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var query = PetaPoco.Sql.Builder.Append(@"SELECT Id, Name
                                                              FROM Department
                                                              WHERE bDeleted=@0 
                                                              AND bActived=@1 
                                                              AND BranchId=@2", false, bActived, branchId);
                    //if (cityId > 0)
                    //{
                    //    query.Append("AND CityId=@0", cityId);
                    //}
                    query.Append("ORDER BY ModifiedDate DESC");
                    list = _uow.Db.Fetch <DepartmentEntity>(query);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoDepartment, "GetDepartment : ", ex.ToString());
            }

            return(list);
        }
Esempio n. 6
0
        protected virtual IConnection CreateDbConnection(IEnumerable <IBaseRepository> repos = null)
        {
            IConnection uow = _unitOfWorkProvider.GetUnitOfWork(repos);

            if (uow.NumberOfRepos > 1)
            {
                uow.BeginTransaction();
            }

            return(uow);
        }
Esempio n. 7
0
        public AccountListEntity GetAll(AccountEntity entity, long pageIndex, long pageSize)
        {
            var list = new AccountListEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var query = PetaPoco.Sql.Builder.Append(@"SELECT * 
                                                              FROM Account 
                                                              WHERE bDeleted=@0", entity.bDeleted);
                    //if (entity.CityId > 0)
                    //{
                    //    query.Append("AND CityId=@0", entity.CityId);
                    //}
                    //if (entity.Star > 0)
                    //{
                    //    query.Append("AND Star=@0", entity.Star);
                    //}
                    query.Append("ORDER BY ModifiedDate DESC");

                    var result = _uow.Db.Page <AccountEntity>(pageIndex, pageSize, query);
                    if (result != null && result.TotalItems > 0)
                    {
                        list.List      = result.Items;                     // danh sách data trả về
                        list.PageTotal = result.TotalPages;                // tổng số Pages
                        list.PageIndex = result.CurrentPage;               // Page hiện tại của data duoc trả về
                        list.Count     = Protector.Int(result.TotalItems); //  count data
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoBranch, "GetAll : ", ex.ToString());
            }
            return(list);
        }