public IActionResult Get(int id) { var repo = this.Storage.GetRepository <IGradingTitleRepository>(); GradingTitle grad = repo.WithKey(id); if (grad == null) { return(this.NotFound(new { success = false })); } return(Ok(new { success = true, data = grad })); }
public IActionResult Post(GradingTitleCreateViewModel model) { if (this.ModelState.IsValid) { GradingTitle grad = model.ToGradingEntity(); var repo = this.Storage.GetRepository <IGradingTitleRepository>(); repo.Create(grad, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = true, data = grad })); } return(BadRequest(new { success = false })); }
public IActionResult Delete(int id) { var repo = this.Storage.GetRepository <IGradingTitleRepository>(); GradingTitle grad = repo.WithKey(id); if (grad == null) { return(this.NotFound(new { success = false })); } repo.Delete(grad, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = "Data berhasil dihapus" })); }
public IActionResult Put(int id, GradingTitleUpdateViewModel model) { var repo = this.Storage.GetRepository <IGradingTitleRepository>(); GradingTitle grad = repo.WithKey(id); if (grad == null) { return(this.NotFound(new { success = false })); } if (this.ModelState.IsValid) { model.ToGradingEntity(grad); repo.Edit(grad, GetCurrentUserName()); this.Storage.Save(); return(Ok(new { success = "Data berhasil diperbaharui" })); } return(BadRequest(new { success = false })); }