Пример #1
0
        public async Task <IHttpActionResult> Delete(string id)
        {
            var    result   = new TransferObj <bool>();
            BOHANG instance = await _service.Repository.FindAsync(id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                _service.Delete(instance.ID);
                int del = await _service.UnitOfWork.SaveAsync();

                if (del > 0)
                {
                    result.Data    = true;
                    result.Status  = true;
                    result.Message = "Xóa thành công bản ghi";
                }
                else
                {
                    result.Data    = false;
                    result.Status  = false;
                    result.Message = "Thao tác không thành công";
                }
            }
            catch (Exception e)
            {
                result.Data    = false;
                result.Status  = false;
                result.Message = e.Message;
            }
            return(Ok(result));
        }
Пример #2
0
            public List <BuildQuery.IQueryFilter> GetFilters()
            {
                var result = new List <IQueryFilter>();
                var refObj = new BOHANG();

                if (!string.IsNullOrEmpty(this.MABOHANG))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.TENBOHANG),
                        Value    = this.MABOHANG,
                        Method   = FilterMethod.Like
                    });
                }
                if (!string.IsNullOrEmpty(this.TENBOHANG))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.TENBOHANG),
                        Value    = this.TENBOHANG,
                        Method   = FilterMethod.Like
                    });
                }
                if (!string.IsNullOrEmpty(this.DIENGIAI))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.DIENGIAI),
                        Value    = this.DIENGIAI,
                        Method   = FilterMethod.Like
                    });
                }
                return(result);
            }