예제 #1
0
 public Keep Post([FromBody] KeepForm keep)
 {
     if (ModelState.IsValid)
     {
         return(_repo.Create(keep));
     }
     throw new Exception("Invalid Keep Object");
 }
예제 #2
0
 public Keep Post([FromBody] Keep keep)
 {
     if (ModelState.IsValid)
     {
         keep.UserId = HttpContext.User.Identity.Name;
         return(_repo.Create(keep));
     }
     throw new Exception("INVALID KEEP");
 }
예제 #3
0
 public Keep Post([FromBody] Keep keep)
 {
     keep.UserId = HttpContext.User.Identity.Name;
     if (ModelState.IsValid)
     {
         keep = new Keep(keep.Name, keep.Description, keep.Img, keep.UserId);
         return _repo.Create(keep);
     }
     throw new Exception("INVALID KEEP");
 }
예제 #4
0
 public ActionResult <Keep> Post([FromBody] Keep data)
 {
     try
     {
         data.UserId = HttpContext.User.FindFirstValue("Id");
         return(Ok(_repo.Create(data)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
예제 #5
0
 public ActionResult <Keep> Post([FromBody] Keep value)
 {
     try
     {
         var id = HttpContext.User.FindFirstValue("Id");
         value.userid = id;
         return(Ok(_repo.Create(value)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
예제 #6
0
        public ActionResult <Keep> Post([FromBody] Keep value)
        {
            var userId = HttpContext.User.FindFirstValue("Id");

            value.UserId = userId;
            if (userId != null)
            {
                return(Ok(_repo.Create(value)));
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #7
0
        public Keep Create([FromBody] Keep keep)
        {
            keep.UserId = HttpContext.User.Identity.Name;
            if (!ModelState.IsValid)
            {
                throw new Exception("Invalid Input");
            }
            Keep newKeep = _repo.Create(keep);

            if (keep == null)
            {
                throw new Exception("Invalid Input");
            }
            return(newKeep);
        }
예제 #8
0
 public ActionResult <Keep> Post([FromBody] Keep value)
 {
     try
     {
         var userId = HttpContext.User.FindFirstValue("Id");
         value.UserId = userId;
         if (userId == null)
         {
             throw new Exception("Login In To Create A Keep");
         }
         return(Ok(_repo.Create(value)));
     }
     catch (Exception e)
     {
         return(BadRequest(e));
     }
 }
예제 #9
0
        public async Task <ActionResult <Keep> > Post([FromBody] Keep value)
        {
            try
            {
                var Userid = HttpContext.User.FindFirstValue("Id");
                value.UserId = Userid;
                var user = _repo.Create(value);
                if (user == null)
                {
                    await HttpContext.SignOutAsync();

                    throw new Exception("User not logged In");
                }
                return(Ok(user));
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
        }