public override void Load() { if (ModelObject == null) { ModelObject = _modelService.CreateModel <NewsItem>(); } }
public ActionResult Create([Bind(Include = "Id,Model,IdDossier")] GEN_Model_Form_ViewModel gEN_Model) { if (ModelState.IsValid) { if (gEN_Model.Id > 0) { gEN_Model.IdDossier = Constantes.CurrentPreferenceIdDossier; ModelPivot modelPivot = Mapper.Map <GEN_Model_Form_ViewModel, ModelPivot>(gEN_Model); modelService.UpdateModel(modelPivot); modelService.SaveModel(); } else { gEN_Model.IdDossier = Constantes.CurrentPreferenceIdDossier; ModelPivot modelPivot = Mapper.Map <GEN_Model_Form_ViewModel, ModelPivot>(gEN_Model); modelService.CreateModel(modelPivot); } return(RedirectToAction("Index")); } ViewBag.IdSociete = new SelectList(dossiersService.GetDossiersByDossiersId(), "DossierId", "DossierRaisonSociale", gEN_Model.IdDossier); return(View(gEN_Model)); }
public ActionResult <Model> Post([FromBody] Model model) { try { return(Ok(_modelService.CreateModel(model))); } catch (ArgumentException e) { return(StatusCode(500, e.Message)); } catch (InvalidOperationException e) { return(StatusCode(500, e.Message)); } }