public Keep Post([FromBody] Keep keep) { if (ModelState.IsValid) { return(_repo.Create(keep)); } throw new Exception("invalid keep"); }
public Keep Post([FromBody] Keep keep) { if (ModelState.IsValid) { keep.UserId = HttpContext.User.Identity.Name; return(_repo.Create(keep)); } throw new Exception("INVALID KEEP"); }
public Keep Post([FromBody] Keep keep) { if (ModelState.IsValid) { keep = new Keep(keep.Name, keep.Description, keep.Username, keep.Img, keep.UserId, keep.IsPrivate); return(_repo.Create(keep)); } throw new Exception("INVALID KEEP"); }
public Keep Post([FromBody] Keep keep) { if (ModelState.IsValid) { Keep newKeep = new Keep(keep.Name, keep.Description, keep.Img, keep.UserId); return(_repo.Create(newKeep)); /// need Username? } throw new System.Exception("Invalid Keep"); }
public Keep Post([FromBody] Keep keep) { if (ModelState.IsValid) { string userId = HttpContext.User.Identity.Name; keep = new Keep(keep.Name, keep.Description, keep.ImgUrl); keep.UserId = userId; return(_repo.Create(keep)); } throw new Exception("INVALID KEEP"); }
public IActionResult Create([FromBody] Keep keep) { if (!ModelState.IsValid) { return(BadRequest("Invalid keep.")); } keep.UserId = HttpContext.User.Identity.Name; try { return(Ok(_repo.Create(keep))); } catch (Exception error) { return(BadRequest(error.Message)); } }
public ActionResult <Keep> Post([FromBody] Keep value) { try { string userId = HttpContext.User.FindFirstValue("Id"); value.UserId = userId; return(Ok(_repo.Create(value))); } catch (Exception e) { return(BadRequest(e)); } }
public Keep Post([FromBody] Keep rawKeep) { if (!ModelState.IsValid) { throw new Exception("Not a valid Keep."); } Keep keep = _repo.Create(rawKeep); if (keep == null) { throw new Exception("Error inserting keep into the db."); } return(keep); }
public Keep Post([FromBody] Keep rawKeep) { if (!ModelState.IsValid) { throw new Exception("Not a valid Keep."); } rawKeep.UserId = HttpContext.User.Identity.Name; Keep keep = _repo.Create(rawKeep); if (keep == null) { throw new Exception("Error inserting keep into the db."); } return(keep); }