public ActionResult Create(Storm.Business.ViewModels.PlayerViewModel model) { try { var validation = _playerAppService.Add(model); if (validation.IsValid) { ViewBag.Success = validation.Message; } else { foreach (var error in validation.Erros) { ModelState.AddModelError(string.Empty, error.Message); } } return(View(model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(model)); } }
public ActionResult Edit(Storm.Business.ViewModels.PlayerViewModel model, FormCollection f) { try { model.PlayerId = ObjectId.Parse(ConvertStringArrayToString((string[])f.GetValue("PlayerId").RawValue)); var validation = _playerAppService.Update(model); if (validation.IsValid) { ViewBag.Success = validation.Message; } else { foreach (var error in validation.Erros) { ModelState.AddModelError(string.Empty, error.Message); } } return(View(model)); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(model)); } }
public ActionResult Delete(Storm.Business.ViewModels.PlayerViewModel model, FormCollection f) { try { model.PlayerId = ObjectId.Parse(ConvertStringArrayToString((string[])f.GetValue("PlayerId").RawValue)); _playerAppService.Remove(model.PlayerId); return(RedirectToAction("Index")); } catch (Exception ex) { ModelState.AddModelError(string.Empty, ex.Message); return(View(model)); } }