public ActionResult Save(vmEntity vm) { if (ModelState.IsValid) { try { _episodeRepository.Save(vm.Episode); return(RedirectToAction("Detail", new { _episodeId = vm.Episode.Id })); } catch (Exception ex) { return(PartialView("_savePanel", vm)); } } return(PartialView("_savePanel", vm)); }
public static void Save(Episode element) { if (element == null) { throw new MediaManagerException($"Erreur : {nameof(element)} is null", ExceptionReturnType.Error); } try { using (var context = new MediaManagerContext()) using (var repository = new EpisodeRepository(context)) { repository.Save(element); context.SaveChanges(); } } catch (Exception ex) { throw new MediaManagerException($"Erreur :{ex.Message}", ExceptionReturnType.Error); } }
public IHttpActionResult Post(Episode episode) { _episodeRepository.Save(episode); return(StatusCode(HttpStatusCode.NoContent)); }