public Event AddEvent(Event newEvent) { newEvent.Id = GenerateNewEventId(); EventMockStorage.Add(newEvent); return newEvent; }
public Event UpdateEvent(Event updatedEvent) { var found = EventMockStorage.SingleOrDefault(e => e.Id == updatedEvent.Id); if (found != null) EventMockStorage.Remove(found); EventMockStorage.Add(updatedEvent); return updatedEvent; }
public ActionResult Create(Event newEvent) { if (!ModelState.IsValid) return View(newEvent); eventRepo.AddEvent(newEvent); EventsHub.NewEvent(); return RedirectToAction("Index"); }
public ActionResult Edit(Event updatedEvent) { if (!ModelState.IsValid) return View(updatedEvent); var result = eventRepo.UpdateEvent(updatedEvent); EventsHub.UpdatedEvent(); return RedirectToAction("Index"); }
public IHttpActionResult Post(Event newEvent) { if (!ModelState.IsValid) return BadRequest(); var result = eventRepo.AddEvent(newEvent); EventsHub.NewEvent(); return Ok(result); }
public IHttpActionResult Put(int id, Event updatedEvent) { if (id != updatedEvent.Id) return BadRequest(); if (!ModelState.IsValid) return BadRequest(); var result = eventRepo.UpdateEvent(updatedEvent); EventsHub.UpdatedEvent(); return Ok(result); }