// GET: MobileApplications/Create public ActionResult Create() { MobileApplicationViewModel mavm = new MobileApplicationViewModel(); mavm.AllAffiliates = db.Affiliates.ToList(); mavm.AllCampaignes = db.Campaignes.ToList(); return View(mavm); }
public ActionResult Create(MobileApplicationViewModel mobileApplication) { if (ModelState.IsValid) { var app = ConvertApplicationModel(mobileApplication); db.MobileApplications.Add(app); db.SaveChanges(); return RedirectToAction("Index"); } return View(mobileApplication); }
private MobileApplication ConvertApplicationModel(MobileApplicationViewModel model) { MobileApplication res = new MobileApplication(); res.Id = model.Id; res.PackageName = model.PackageName; res.Owner = db.Affiliates.Find(model.AffilateId); res.AdCampaign = db.Campaignes.Find(model.CampaignId); return res; }