Example #1
0
 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");
 }
Example #3
0
 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");
 }
Example #4
0
 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");
 }
Example #5
0
 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");
 }
Example #6
0
 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));
     }
 }
Example #7
0
 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));
     }
 }
Example #8
0
        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);
        }
Example #9
0
        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);
        }