public async Task <IActionResult> Edit(int id, [Bind("id,event_type,date,place,name,hour,tickets,tickets_per_person,organizer")] EventsModel eventsModel)
 {
     if (id != eventsModel.id)
     {
         return(NotFound());
     }
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(eventsModel);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!EventsModelExists(eventsModel.id))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(View(eventsModel));
 }
Ejemplo n.º 2
0
        public IActionResult EditEvent([FromBody] EventModel eventData, int?year, int?month, int?day)
        {
            if (!year.HasValue ||
                !month.HasValue ||
                !day.HasValue ||
                eventData == null ||
                eventData.ID == null ||
                eventData.Time == null ||
                eventData.Name == null)
            {
                return(BadRequest());
            }

            try
            {
                var date = new DateTime(year.Value, month.Value, day.Value, eventData.Time.Value.Hours, eventData.Time.Value.Minutes, eventData.Time.Value.Seconds);
                eventBase.Update(eventData.ID.Value, date, eventData.Name);

                return(Ok());
            }
            catch
            {
                return(StatusCode(500));
            }
        }