Exemplo n.º 1
0
        public MessageEntity Create(GroupPageEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    int Id = Protector.Int(_uow.Db.Insert(entity));
                    if (Id > 0)
                    {
                        msgEntity.code    = 0;
                        msgEntity.result  = true;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;

                        _uow.Commit();
                    }
                    else
                    {
                        msgEntity.code    = -2;
                        msgEntity.result  = false;
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_ERR;
                    }
                }
            }
            catch (Exception ex)
            {
                msgEntity.code    = -1;
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoGroupPage, "Create : ", ex.ToString());
            }
            return(msgEntity);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        public MessageEntity Update(GroupPageEntity entity)
        {
            var msgEntity = new MessageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    var data = _uow.Db.SingleOrDefault <BranchEntity>("SELECT * FROM GroupPage WHERE Id=@0", entity.Id);
                    if (data != null && data.Id == entity.Id)
                    {
                        entity.CreatedBy   = data.CreatedBy;
                        entity.CreatedDate = data.CreatedDate;
                        _uow.Db.Update(entity);
                        msgEntity.message = ConstantsHandler.ErrorMessage.Message_OK;
                        msgEntity.result  = true;
                        msgEntity.code    = 0;
                    }
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                msgEntity.result  = false;
                msgEntity.message = ConstantsHandler.ErrorMessage.Message_EX;
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoGroupPage, "Update : ", ex.ToString());
            }

            return(msgEntity);
        }
Exemplo n.º 4
0
        public GroupPageEntity GetById(int id)
        {
            var entity = new GroupPageEntity();

            try
            {
                using (var _uow = _unitOfWorkProvider.GetUnitOfWork())
                {
                    entity = _uow.Db.SingleOrDefault <GroupPageEntity>("SELECT * FROM GroupPage WHERE Id=@0", id);
                    _uow.Commit();
                }
            }
            catch (Exception ex)
            {
                Logger.ErrorLog(ConstantsHandler.ForderLogName.RepoGroupPage, "GetById : ", ex.ToString());
            }

            return(entity);
        }