Beispiel #1
0
        public async Task <IActionResult> OnPostAsync([FromBody] Event Event)
        {
            if (ModelState.IsValid)
            {
                EventRepo e      = new EventRepo(_context);
                var       result = e.Create(Event.EventName, Event.Description, Event.Date, Event.Time);
                if (result)
                {
                    var res = new
                    {
                        StatusCode = "Ok",
                        EventName  = Event.EventName
                    };

                    return(new ObjectResult(res));
                }
            }


            var invalidRes = new
            {
                StatusCode = "Invalid",
                EventName  = Event.EventName
            };


            return(new ObjectResult(invalidRes));
        }
Beispiel #2
0
 public IActionResult Create([FromBody] EventVM eventVM)
 {
     if (ModelState.IsValid)
     {
         var success = _eventRepo.Create(eventVM);
         return(success ? StatusCode(201) : StatusCode(422));
     }
     return(StatusCode(400));
 }