public MdWareHouse FilterWareHouse(string maKho) { var wareHouse = new MdWareHouse(); if (string.IsNullOrEmpty(maKho)) { wareHouse = null; } else { maKho = maKho.ToUpper(); maKho = maKho.Trim(); var unitCode = _service.GetCurrentUnitCode(); wareHouse = _service.Repository.DbSet.Where(x => x.MaKho == maKho).FirstOrDefault(x => x.UnitCode == unitCode); if (wareHouse != null) { return(wareHouse); } else { wareHouse = null; } } return(wareHouse); }
public async Task <IHttpActionResult> Delete(string id) { MdWareHouse 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 async Task <IHttpActionResult> Put(string id, MdWareHouse instance) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != instance.Id) { return(BadRequest()); } var result = new TransferObj <MdWareHouse>(); if (id != instance.Id) { result.Status = false; result.Message = "Id không hợp lệ"; return(Ok(result)); } try { var item = _service.Update(instance); _service.UnitOfWork.Save(); result.Status = true; result.Data = item; result.Message = "Cập nhật thành công"; return(Ok(result)); } catch (Exception e) { result.Status = false; result.Message = e.Message; return(Ok(result)); } }
public List <IQueryFilter> GetFilters() { var result = new List <IQueryFilter>(); var refObj = new MdWareHouse(); if (!string.IsNullOrEmpty(this.MaKho)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaKho), Value = this.MaKho, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.TenKho)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.TenKho), Value = this.TenKho, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.UnitCode)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.UnitCode), Value = this.UnitCode, Method = FilterMethod.StartsWith }); } if (!string.IsNullOrEmpty(this.TaiKhoanKt)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.TaiKhoanKt), Value = this.TaiKhoanKt, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.MaCuaHang)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaCuaHang), Value = this.MaCuaHang, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.DiaChi)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.DiaChi), Value = this.DiaChi, Method = FilterMethod.Like }); } if (!string.IsNullOrEmpty(this.ThongTinBoSung)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.ThongTinBoSung), Value = this.ThongTinBoSung, Method = FilterMethod.Like }); } return(result); }