public IActionResult Get(string id)
        {
            long ID = 0;

            if (long.TryParse(id, out ID))
            {
                Organization org = _srv.GetOrg(ID);
                if (org != null)
                {
                    return(Ok(org));
                }
                return(NotFound($"Couldn't find user with ID: {ID}!"));
            }
            return(BadRequest("Couldn't parse user ID!"));
        }
Esempio n. 2
0
        public IActionResult Post(Event model)
        {
            if (ModelState.IsValid)
            {
                /*Event ev = new Event() {
                 *      EventID = model.EventID,
                 *      Name = model.Name,
                 *      DateTime = model.DateTime,
                 *      Location = model.Location,
                 *      Info = model.Info,
                 *      IsPublic = model.IsPublic,
                 *      OrganizationID = model.OrganizationID,
                 *      // Organization = _srv.GetOrg(model.OrganizationID)
                 * };*/
                //Organization org = _srv.GetOrg(model.OrganizationID);
                //org.Events.Add(model);
                System.Console.WriteLine(model);
                //FIXME: remove org id?
                Organization org = _srv.GetOrg(model.OrganizationID);
                model.Organization = org;
                Event postevent = new Event(model.EventID, model.Name, model.Info, model.DateTime, model.Location, org);

                // System.Console.Write(org);
                if (_srv.PostEvent(postevent))
                {
                    // FIXME: remove org before passing back (for recurssion error))
                    // return ev for confirmation page or nothing?
                    return(Ok(model));
                }
                return(BadRequest("Creating event failed!"));
            }
            return(BadRequest("Event model is invalid!"));
        }