public IActionResult PostFarmRight([FromBody] FarmRight farmRight) { try { context.FarmRights.Add(farmRight); context.SaveChanges(); string url = Url.ActionContext.HttpContext.Request.Path; return(Created(url, farmRight)); } catch (Exception ex) { return(StatusCode(500)); } }
public IActionResult GetFarmRight(Guid id) { try { FarmRight farmRight = context.FarmRights.Find(id); if (farmRight == null) { return(NotFound()); } return(Ok(farmRight)); } catch (Exception ex) { return(StatusCode(500)); } }
public IActionResult PutFarmRight([FromBody] FarmRight farmRight) { try { if (!context.FarmRights.Any(fr => fr.Id == farmRight.Id)) { return(NotFound()); } context.FarmRights.Update(farmRight); context.SaveChanges(); return(Ok(farmRight)); } catch (Exception ex) { return(StatusCode(500)); } }
public IActionResult DeleteFarmRight(Guid id) { try { FarmRight farmRight = context.FarmRights.Find(id); if (farmRight == null) { return(NotFound()); } context.FarmRights.Remove(farmRight); context.SaveChanges(); return(Ok()); } catch (Exception ex) { return(StatusCode(500)); } }