public ActionResult CreateReferral(CreateReferralViewModel model) { var api = Platform.Core.Api.Instance; if (!ModelState.IsValid) { model.games = getGameList(); return View("Create", model); } var referrer = this._mapper.Map<ReferralCampaign>(model); var game = api.GetReferralGames().Data.Where(x => x.id == model.game_id).FirstOrDefault(); if (game != null) referrer.game_name = game.name; else return RedirectToAction("CampaignList"); referrer.status = (int)ReferralCampaignStatus.Active; if (!referrer.is_display_only) { string validate = ValidateListCampaigns(model.game_id.Value, model.start_date, model.end_date, 0); if (!string.IsNullOrEmpty(validate)) { model.games = getGameList(); ViewBag.Error = validate; return View("Create", model); } } api.CreateReferralCampaign(referrer); return RedirectToAction("CampaignList"); }
public ActionResult Create() { var api = Platform.Core.Api.Instance; var model = new CreateReferralViewModel(); var games = api.GetReferralGames(); if (games.HasData) model.games = games.Data; return View(model); }