Example #1
0
            public List <IQueryFilter> GetFilters()
            {
                var result = new List <IQueryFilter>();
                var refObj = new NvNgayHetHanHangHoa();

                if (!string.IsNullOrEmpty(this.MaPhieu))
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.MaPhieu),
                        Value    = this.MaPhieu,
                        Method   = FilterMethod.Like
                    });
                }
                if (this.NgayBaoDate.HasValue)
                {
                    result.Add(new QueryFilterLinQ
                    {
                        Property = ClassHelper.GetProperty(() => refObj.NgayBaoDate),
                        Value    = this.NgayBaoDate.Value,
                        Method   = FilterMethod.EqualTo
                    });
                }
                return(result);
            }
Example #2
0
        public async Task <IHttpActionResult> Post(NvNgayHetHanHangHoaVm.Dto instance)
        {
            TransferObj <NvNgayHetHanHangHoa> result = new TransferObj <NvNgayHetHanHangHoa>();

            try
            {
                NvNgayHetHanHangHoa item = _service.InsertPhieu(instance);
                await _service.UnitOfWork.SaveAsync();

                result.Data   = item;
                result.Status = true;
                return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }
Example #3
0
        public async Task <IHttpActionResult> GetDetails(string id)
        {
            string _ParentUnitCode = _service.GetParentUnitCode();
            TransferObj <NvNgayHetHanHangHoaVm.Dto> result = new TransferObj <NvNgayHetHanHangHoaVm.Dto>();

            NvNgayHetHanHangHoaVm.Dto temp  = new NvNgayHetHanHangHoaVm.Dto();
            NvNgayHetHanHangHoa       phieu = _service.FindById(id);

            if (phieu != null)
            {
                temp = Mapper.Map <NvNgayHetHanHangHoa, NvNgayHetHanHangHoaVm.Dto>(phieu);
                List <NvNgayHetHanHangHoaChiTiet> chiTietPhieu = _service.UnitOfWork.Repository <NvNgayHetHanHangHoaChiTiet>().DbSet.Where(x => x.MaPhieuPk == phieu.MaPhieuPk).ToList();
                temp.DataDetails = Mapper.Map <List <NvNgayHetHanHangHoaChiTiet>, List <NvNgayHetHanHangHoaVm.DtoDetail> >(chiTietPhieu);
            }
            result.Data   = temp;
            result.Status = true;
            return(Ok(result));
        }
Example #4
0
        public async Task <IHttpActionResult> Delete(string id)
        {
            NvNgayHetHanHangHoa instance = await _service.Repository.FindAsync(id);

            if (instance == null)
            {
                return(NotFound());
            }
            try
            {
                if (_service.DeletePhieu(id))
                {
                    _service.Delete(instance.Id);
                    _service.UnitOfWork.Save();
                    return(Ok(instance));
                }
                return(InternalServerError());
            }
            catch (Exception e)
            {
                WriteLogs.LogError(e);
                return(InternalServerError());
            }
        }
Example #5
0
        public async Task <IHttpActionResult> Put(string id, NvNgayHetHanHangHoaVm.Dto instance)
        {
            TransferObj <NvNgayHetHanHangHoa> result = new TransferObj <NvNgayHetHanHangHoa>();

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            NvNgayHetHanHangHoa check = _service.FindById(instance.Id);

            try
            {
                NvNgayHetHanHangHoa item = _service.UpdatePhieu(instance);
                await _service.UnitOfWork.SaveAsync();

                result.Status = true;
                result.Data   = item;
                return(Ok(result));
            }
            catch (Exception e)
            {
                return(InternalServerError());
            }
        }