public async Task <IHttpActionResult> Delete(string id) { MdContract instance = await _service.Repository.FindAsync(id); if (instance == null) { return(NotFound()); } try { _service.Delete(instance.Id); await _service.UnitOfWork.SaveAsync(); return(Ok(instance)); } catch (Exception) { return(InternalServerError()); } }
public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new MdContract(); if (!string.IsNullOrEmpty(this.MaHd))//MaHD { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaHd), Value = this.MaHd, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.TenHd)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.TenHd), Value = this.TenHd, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.GiaTriHD)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.GiaTriHD), Value = this.GiaTriHD, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.KhachHang)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.KhachHang), Value = this.KhachHang, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.NguoiLienHe)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NguoiLienHe), Value = this.NguoiLienHe, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.DonViThucHien)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.DonViThucHien), Value = this.DonViThucHien, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.NguoiThucHien)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NguoiThucHien), Value = this.NguoiThucHien, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.LyDo)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.LyDo), Value = this.LyDo, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.DieuKhoanKhac)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.DieuKhoanKhac), Value = this.DieuKhoanKhac, Method = FilterMethod.Like }); } if (this.TuNgayKy.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayKy), Value = this.TuNgayKy.Value, Method = FilterMethod.GreaterThanOrEqualTo }); } if (this.DenNgayKy.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayKy), Value = this.DenNgayKy.Value.AddDays(1), Method = FilterMethod.LessThan }); } if (this.TuNgayHetHan.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayThanhLy), Value = this.TuNgayKy.Value, Method = FilterMethod.GreaterThanOrEqualTo }); } if (this.DenNgayHetHan.HasValue) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.NgayThanhLy), Value = this.DenNgayHetHan.Value.AddDays(1), Method = FilterMethod.LessThan }); } return(result); }