public async Task <IHttpActionResult> Put(string id, NvCongNoVm.Dto instance) { TransferObj <NvCongNo> result = new TransferObj <NvCongNo>(); NvCongNo check = _service.FindById(instance.Id); if (id != instance.Id || check.TrangThai == (int)ApprovalState.IsComplete) { result.Status = false; result.Message = "Dữ liệu không đúng!"; return(Ok(result)); } try { NvCongNo item = _service.UpdatePhieu(instance); await _service.UnitOfWork.SaveAsync(); result.Status = true; result.Message = "Update thành công!"; result.Data = item; } catch (Exception e) { WriteLogs.LogError(e); result.Status = false; result.Message = e.Message.ToString(); } return(Ok(result)); }
public async Task <IHttpActionResult> GetDetails(string id) { TransferObj <NvCongNoVm.Dto> result = new TransferObj <NvCongNoVm.Dto>(); NvCongNoVm.Dto temp = new NvCongNoVm.Dto(); NvCongNo phieu = _service.FindById(id); if (phieu != null) { temp = Mapper.Map <NvCongNo, NvCongNoVm.Dto>(phieu); result.Data = temp; result.Status = true; return(Ok(result)); } return(NotFound()); }
public async Task <IHttpActionResult> Delete(string id) { NvCongNo instance = await _service.Repository.FindAsync(id); if (instance == null) { return(NotFound()); } try { _service.Delete(instance.Id); _service.UnitOfWork.Save(); return(Ok(instance)); } catch (Exception) { return(InternalServerError()); } }
public async Task <IHttpActionResult> Post(NvCongNoVm.Dto instance) { TransferObj <NvCongNo> result = new TransferObj <NvCongNo>(); try { NvCongNo item = _service.InsertPhieu(instance); await _service.UnitOfWork.SaveAsync(); result.Data = item; result.Message = "Thêm mới thành công"; result.Status = true; return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result)); } catch (Exception e) { WriteLogs.LogError(e); result.Message = e.Message.ToString(); result.Status = false; } return(Ok(result)); }
public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new NvCongNo(); if (!string.IsNullOrEmpty(this.MaChungTu)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaChungTu), Value = this.MaChungTu, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MaKhachHang)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaKhachHang), Value = this.MaKhachHang, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MaNhaCungCap)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaNhaCungCap), Value = this.MaNhaCungCap, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.GhiChu)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.GhiChu), Value = this.GhiChu, Method = FilterMethod.Like }); } if (this.TuNgay.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayCT), Value = this.TuNgay.Value, Method = FilterMethod.GreaterThanOrEqualTo }); } if (this.DenNgay.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayCT), Value = this.DenNgay.Value.AddDays(1), Method = FilterMethod.LessThan }); } return(result); }