public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new NvKiemKe(); if (!string.IsNullOrEmpty(this.KeKiemKe)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.KeKiemKe), Value = this.LoaiVatTu, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MaPhieuKiemKe)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaPhieuKiemKe), Value = this.MaPhieuKiemKe, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.NguoiTao)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NguoiTao), Value = this.NguoiTao, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.SoPhieuKiemKe)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.SoPhieuKiemKe), Value = this.SoPhieuKiemKe, Method = FilterMethod.Like }); } if (this.NgayKiemKe.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayKiemKe), Value = this.NgayKiemKe.Value, Method = FilterMethod.GreaterThanOrEqualTo }); } return(result); }
public async Task <IHttpActionResult> Put(string id, NvKiemKeVm.Dto instance) { //Lấy danh sách các mã không thuộc kệ để update lại mã kệ cho các mã đó List <NvKiemKeVm.DtoDetails> hangKhongThuocKe = new List <NvKiemKeVm.DtoDetails>(); foreach (NvKiemKeVm.DtoDetails data in instance.DataDetails) { if (data.KeKiemKe == instance.KeKiemKe) { } else { hangKhongThuocKe.Add(data); } } //Update mã kệ trong danh mục hàng hóa foreach (NvKiemKeVm.DtoDetails value in hangKhongThuocKe) { MdMerchandise maHangHoa = _service.Repository.DbSet.FirstOrDefault(x => x.MaVatTu == value.MaVatTu); if (maHangHoa != null) { maHangHoa.MaKeHang = instance.KeKiemKe; _service.Update(maHangHoa); } } await _service.UnitOfWork.SaveAsync(); //end cập nhật mã kệ TransferObj <NvKiemKe> result = new TransferObj <NvKiemKe>(); NvKiemKe check = _serviceKK.FindById(instance.Id); if (id != instance.Id || check.TrangThai == (int)ApprovalState.IsComplete) { return(NotFound()); } try { NvKiemKe item = _serviceKK.UpdatePhieu(instance); await _serviceKK.UnitOfWork.SaveAsync(); result.Status = true; result.Data = item; return(Ok(result)); } catch (Exception e) { return(InternalServerError()); } }
public async Task <IHttpActionResult> Post(NvKiemKeVm.Dto instance) { TransferObj <NvKiemKe> result = new TransferObj <NvKiemKe>(); try { NvKiemKe item = _serviceKK.InsertPhieu(instance); await _serviceKK.UnitOfWork.SaveAsync(); result.Data = item; result.Status = true; return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.MaPhieuKiemKe }, result)); } catch (Exception e) { return(InternalServerError()); } }
public async Task <IHttpActionResult> GetDetails(string id) { TransferObj <NvKiemKeVm.Dto> result = new TransferObj <NvKiemKeVm.Dto>(); NvKiemKeVm.Dto temp = new NvKiemKeVm.Dto(); NvKiemKe phieu = _serviceKK.FindById(id); if (phieu != null) { temp = Mapper.Map <NvKiemKe, NvKiemKeVm.Dto>(phieu); List <NvKiemKeChiTiet> chiTietPhieu = _service.UnitOfWork.Repository <NvKiemKeChiTiet>().DbSet.Where(x => x.MaPhieuKiemKe == phieu.MaPhieuKiemKe).ToList(); temp.DataDetails = Mapper.Map <List <NvKiemKeChiTiet>, List <NvKiemKeVm.DtoDetails> >(chiTietPhieu); result.Data = temp; result.Status = true; return(Ok(result)); } return(NotFound()); }
public async Task <IHttpActionResult> Delete(string id) { NvKiemKe instance = await _serviceKK.Repository.FindAsync(id); if (instance == null) { return(NotFound()); } try { _serviceKK.DeletePhieu(instance.Id); await _serviceKK.UnitOfWork.SaveAsync(); return(Ok(instance)); } catch (Exception) { return(InternalServerError()); } }
public async Task <IHttpActionResult> PostComplete(NvKiemKeVm.Dto instance) { string unitCode = _service.GetCurrentUnitCode(); MdPeriod curentDate = CurrentSetting.GetKhoaSo(unitCode); int period = curentDate.Period; int year = curentDate.Year; string tablleName = curentDate.GetTableName(); NvKiemKe phieuKiemKe = _serviceKK.FindById(instance.Id); instance.NgayDuyetPhieu = curentDate.ToDate; //thực hiện tạo phiếu kiểm kê nhập, kiểm kê xuất try { _serviceKK.Approval(instance, tablleName, year.ToString(), period); _serviceKK.UpdateApproval(instance); _serviceKK.UnitOfWork.Save(); return(Ok(true)); } catch (Exception) { return(InternalServerError()); } }