public async Task <IActionResult> get([FromQuery] string key, [FromQuery] string order, [FromQuery] bool?ascending = false, [FromQuery] int?page = 1, [FromQuery] int?size = 10, [FromQuery] statusList statusList = statusList.Active) { var lists = await _listQ.getAll(key : key, order : order, ascending : (bool)ascending, page : (int)page, size : (int)size, statusList : statusList); var listcount = await _listQ.getAllCount(key : key, order : order, ascending : (bool)ascending, statusList : statusList); return(TempRes.result(200, Request.GetDisplayUrl(), lists, null, listcount)); }
public async Task <IActionResult> delete(long idList) { var listdelete = await _listQ.updateStatus(idList, statusList.Deleted); if (listdelete == null) { return(TempRes.result(404, Request.GetDisplayUrl(), listdelete, "Data List Tidak Ditemukan")); } return(TempRes.result(200, Request.GetDisplayUrl(), listdelete)); }
public async Task <IActionResult> delete(long idListItem) { var listItemdelete = await _listItemQ.delete(idListItem); if (listItemdelete == null) { return(TempRes.result(404, Request.GetDisplayUrl(), listItemdelete, "Data List Item Tidak Ditemukan")); } return(TempRes.result(200, Request.GetDisplayUrl(), listItemdelete)); }
public async Task <IActionResult> toggleStatus(long idListItem) { var listItemupdate = await _listItemQ.toggleStatus(idListItem); if (listItemupdate == null) { return(TempRes.result(404, Request.GetDisplayUrl(), null, "Data List Item Tidak Ditemukan")); } return(TempRes.result(200, Request.GetDisplayUrl(), listItemupdate)); }
public async Task <IActionResult> getDetail(long idList) { var list = await _listQ.getDetail(idList); if (list == null) { return(TempRes.result(404, Request.GetDisplayUrl(), list, "Data List Tidak Ditemukan")); } if (list.statusList == statusList.Deleted) { return(TempRes.result(401, Request.GetDisplayUrl(), null, "List Tidak Aktif")); } return(TempRes.result(200, Request.GetDisplayUrl(), list, null)); }
public async Task <IActionResult> post([FromBody] ListInsert list) { if (list == null) { return(TempRes.result(400, Request.GetDisplayUrl(), list, "Data List Tidak Boleh Kosong")); } // MODELSTATE BASED VALIDATION ModelState.Clear(); TryValidateModel(list); if (!ModelState.IsValid) { return(TempRes.result(400, Request.GetDisplayUrl(), list, ModelState.Values.SelectMany(ms => ms.Errors).FirstOrDefault().ErrorMessage)); } var newlist = await _listQ.insert(list); return(TempRes.result(200, Request.GetDisplayUrl(), newlist)); }
public async Task <IActionResult> put([FromBody] ListItemUpdate listItem) { if (listItem == null) { return(TempRes.result(400, Request.GetDisplayUrl(), listItem, "Data List Item Tidak Boleh Kosong")); } // MODELSTATE BASED VALIDATION ModelState.Clear(); TryValidateModel(listItem); if (!ModelState.IsValid) { return(TempRes.result(400, Request.GetDisplayUrl(), listItem, ModelState.Values.SelectMany(ms => ms.Errors).FirstOrDefault().ErrorMessage)); } var listItemupdate = await _listItemQ.update(listItem); if (listItemupdate == null) { return(TempRes.result(404, Request.GetDisplayUrl(), listItem, "Data List Item Tidak Ditemukan")); } return(TempRes.result(200, Request.GetDisplayUrl(), listItemupdate)); }