예제 #1
0
        public IActionResult Get(string id)
        {
            long ID = 0;

            if (long.TryParse(id, out ID))
            {
                User user = _srv.GetUser(ID);
                if (user != null)
                {
                    return(Ok(user));
                }
                return(NotFound($"Couldn't find user with ID: {ID}!"));
            }
            return(BadRequest("Couldn't parse user ID!"));
        }
예제 #2
0
        public IActionResult UserEventPut(UserEvent model)
        {
            if (ModelState.IsValid)
            {
                if (model.EventID != 0L && model.UserID != 0L)
                {
                    Event ev   = _srv.GetEvent(model.EventID);
                    User  user = _srv.GetUser(model.UserID);

                    UserEvent post = new UserEvent(model.UserEventID, user, ev);

                    if (_srv.PostUserEvent(post))
                    {
                        return(Ok());
                    }
                    return(BadRequest("Putting event failed!"));
                }
                return(NotFound($"Couldn't find event with id: \"{model.EventID}\"!"));
            }
            return(BadRequest("Event model is invalid!"));
        }