コード例 #1
0
ファイル: LagController.cs プロジェクト: goldnarms/GiveBack
 public ActionResult Opprett(LagViewModel lagViewModel)
 {
     if (ModelState.IsValid)
     {
         Mapper.CreateMap<LagViewModel, Lag>();
         Mapper.CreateMap<PersonViewModel, Person>();
         var lag = new Lag();
         var person = new Person();
         Mapper.Map(lagViewModel.TeamLeder, person);
         entities.Person.AddObject(person);
         entities.SaveChanges();
         lagViewModel.TeamLederId = person.Id;
         Mapper.Map(lagViewModel, lag);
         lag.LagKategori = entities.LagKategori.SingleOrDefault(kategori => kategori.Id == lagViewModel.LagKategoriId);
         entities.Lag.AddObject(lag);
         entities.SaveChanges();
         return RedirectToAction("Opprett", "Aksjon", new { lagId = lag.Id});
     }
     return View();
 }
コード例 #2
0
 /// <summary>
 /// Create a new Lag object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="navn">Initial value of the Navn property.</param>
 /// <param name="teamLederId">Initial value of the TeamLederId property.</param>
 /// <param name="lagKategoriId">Initial value of the LagKategoriId property.</param>
 public static Lag CreateLag(global::System.Int32 id, global::System.String navn, global::System.Int32 teamLederId, global::System.Int32 lagKategoriId)
 {
     Lag lag = new Lag();
     lag.Id = id;
     lag.Navn = navn;
     lag.TeamLederId = teamLederId;
     lag.LagKategoriId = lagKategoriId;
     return lag;
 }
コード例 #3
0
 public int Add(Lag lag)
 {
     int id = lagRep.Count + 1;
     lagRep.Add(id, lag);
     return id;
 }
コード例 #4
0
 /// <summary>
 /// Deprecated Method for adding a new object to the Lag EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToLag(Lag lag)
 {
     base.AddObject("Lag", lag);
 }