public ResponseModel <bool> Delete(int id) { var resp = new ResponseModel <bool>(); try { if (id == 0) { throw new Exception("Id not found"); } var groupObj = AppRepo.GetById(id); if (groupObj != null) { AppRepo.Delete(groupObj); resp.Status = 200; resp.Data = true; resp.Description = "OK"; } else { throw new Exception("id not exist"); } } catch (Exception ex) { resp.Status = 500; resp.Description = $"Error: {ex.Message}"; resp.Data = true; } return(resp); }
public ResponseModel <bool> Put([FromBody] GroupModel applicationData) { var resp = new ResponseModel <bool>(); try { if (applicationData == null) { throw new Exception("no data"); } var groupObj = AppRepo.GetById(applicationData.Id); if (groupObj != null) { groupObj.Id = applicationData.Id; if (applicationData.Name != null) { groupObj.Name = applicationData.Name; } if (applicationData.Description != null) { groupObj.Description = applicationData.Description; } if (applicationData.IsActive != null) { groupObj.IsActive = applicationData.IsActive; } if (applicationData.IsDelete != null) { groupObj.IsDelete = applicationData.IsDelete; } if (applicationData.Date != null) { groupObj.Date = applicationData.Date; } AppRepo.Update(groupObj); resp.Status = 200; resp.Data = true; resp.Description = "OK"; } else { throw new Exception("Group not exist"); } } catch (Exception ex) { resp.Status = 500; resp.Description = $"Error: {ex.Message}"; resp.Data = true; } return(resp); }