public async Task <IActionResult> GetAll() { var spklu = new SKPLURepo(_db); var result = await spklu.GetAll(); return(Ok(result)); }
public async Task <IActionResult> GetByID(string id) { long.TryParse(id.FromBase64(), out long ID); var spklu = new SKPLURepo(_db); var result = await spklu.GetByID(ID); if (result.SKPLUID == 0) { return(NotFound($"Data Not Found")); } return(Ok(result)); }
public async Task <IActionResult> Insert(SKPLUViewModel model) { var repo = new SKPLURepo(_db); model.CreatedBy = 0; model.CreatedDate = DateTime.Now; if (ModelState.IsValid) { var result = await repo.Insert(model); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }
public async Task <IActionResult> Update(SKPLUViewModel model) { var repo = new SKPLURepo(_db); model.ModifyBy = 1; model.ModifyDate = DateTime.Now; if (ModelState.IsValid) { var result = await repo.Update(model); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }
public async Task <IActionResult> Delete(string id) { long.TryParse(id.FromBase64(), out long ID); var repo = new SKPLURepo(_db); var model = await repo.GetByID(ID); if (model.SKPLUID == 0) { return(NotFound($"Data Not Found")); } model.ModifyBy = 1; model.ModifyDate = DateTime.Now; if (ModelState.IsValid) { var result = await repo.Delete(model); if (result.Success) { return(Ok(result)); } return(BadRequest(result)); } return(BadRequest()); }