public async Task <IHttpActionResult> Put(string id, MdChietKhauKH instance) { var result = new TransferObj <MdChietKhauKH>(); 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 MdChietKhauKH(); if (!string.IsNullOrEmpty(this.MaChietKhau)) { result.Add(new QueryFilterLinQ { Property = ClassHelper.GetProperty(() => refObj.MaChietKhau), Value = this.MaChietKhau, Method = FilterMethod.Like }); } return(result); }
public async Task <IHttpActionResult> Delete(string id) { MdChietKhauKH 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> Post(MdChietKhauKH instance) { var result = new TransferObj <MdChietKhauKH>(); try { var item = _service.Insert(instance); _service.UnitOfWork.Save(); result.Status = true; result.Message = "Thêm mới thành công"; result.Data = item; } catch (Exception e) { result.Status = false; result.Message = e.Message; return(Ok(result)); } return(CreatedAtRoute("DefaultApi", new { controller = this, id = instance.Id }, result)); }