Esempio n. 1
0
            public List <IQueryFilter> GetFilters()
            {
                var result = new List <IQueryFilter>();
                var refObj = new AU_NHOMQUYEN();

                if (!string.IsNullOrEmpty(this.MANHOMQUYEN))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.MANHOMQUYEN),
                        Value    = this.MANHOMQUYEN,
                        Method   = FilterMethod.Like
                    });
                }
                if (!string.IsNullOrEmpty(this.TENNHOMQUYEN))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.TENNHOMQUYEN),
                        Value    = this.TENNHOMQUYEN,
                        Method   = FilterMethod.Like
                    });
                }
                if (!string.IsNullOrEmpty(this.MOTA))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.MOTA),
                        Value    = this.MOTA,
                        Method   = FilterMethod.Like
                    });
                }

                return(result);
            }
Esempio n. 2
0
        public IHttpActionResult Update(string id, AU_NHOMQUYEN instance)
        {
            var _unitCode = _service.GetCurrentUnitCode();
            var result    = new TransferObj <AU_NHOMQUYEN>();

            if (id != instance.Id)
            {
                result.Status  = false;
                result.Message = "Id không hợp lệ";
            }
            else
            {
                try
                {
                    instance.UnitCode = _unitCode;
                    var item = _service.Update(instance);
                    _service.UnitOfWork.Save();
                    result.Status  = true;
                    result.Message = "Cập nhật thành công.";
                    result.Data    = item;
                }
                catch (Exception e)
                {
                    result.Status  = false;
                    result.Message = e.Message;
                }
            }
            return(Ok(result));
        }
Esempio n. 3
0
        public IHttpActionResult Add(AU_NHOMQUYEN instance)
        {
            var _unitCode = _service.GetCurrentUnitCode();
            var result    = new TransferObj <AU_NHOMQUYEN>();

            try
            {
                instance.UnitCode = _unitCode;
                var item = _service.Insert(instance);
                _service.UnitOfWork.Save();
                result.Status  = true;
                result.Message = "Cập nhật thành công.";
                result.Data    = item;
            }
            catch (Exception e)
            {
                result.Status  = false;
                result.Message = e.Message;
            }
            return(Ok(result));
        }
Esempio n. 4
0
        public IHttpActionResult DeleteItem(string Id)
        {
            AU_NHOMQUYEN instance = _service.FindById(Id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                var result = new TransferObj <AU_NHOMQUYEN>();
                _service.Delete(instance.Id);
                _service.UnitOfWork.Save();
                result.Status  = true;
                result.Message = "Xóa thành công.";
                return(Ok(result));
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }
Esempio n. 5
0
        public IHttpActionResult DeleteItem(string Id)
        {
            AU_NHOMQUYEN instance = _service.FindById(Id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                if (_service.DeleteNhomQuyen(Id))
                {
                    _service.Delete(instance.Id);
                    _service.UnitOfWork.Save();
                    return(Ok(instance));
                }
                return(InternalServerError());
            }
            catch (Exception)
            {
                return(InternalServerError());
            }
        }