示例#1
0
 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
 public ActionResult Opprett(Person person)
 {
     entities.Person.AddObject(person);
     entities.SaveChanges();
     return View();
 }
 /// <summary>
 /// Deprecated Method for adding a new object to the Person EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
 /// </summary>
 public void AddToPerson(Person person)
 {
     base.AddObject("Person", person);
 }
 /// <summary>
 /// Create a new Person object.
 /// </summary>
 /// <param name="id">Initial value of the Id property.</param>
 /// <param name="fornavn">Initial value of the Fornavn property.</param>
 /// <param name="etternavn">Initial value of the Etternavn property.</param>
 /// <param name="epost">Initial value of the Epost property.</param>
 /// <param name="mobil">Initial value of the Mobil property.</param>
 public static Person CreatePerson(global::System.Int32 id, global::System.String fornavn, global::System.String etternavn, global::System.String epost, global::System.String mobil)
 {
     Person person = new Person();
     person.Id = id;
     person.Fornavn = fornavn;
     person.Etternavn = etternavn;
     person.Epost = epost;
     person.Mobil = mobil;
     return person;
 }