Пример #1
0
        public ActionResult Create(BookViewModel bvm)
        {
            if (ModelState.IsValid)
            {

                Entry entry = new Entry();
                Contact c = new Contact();
                entry.Id = bvm.EntryID;
                entry.Room = bvm.room;
                entry.StartDate = bvm.StartDate;
                entry.EndDate = bvm.EndDate;
                entry.AmountOfPeople = bvm.AmountOfPeople;
                c.Adress = bvm.Adress;
                c.Email = bvm.Email;
                c.Id = bvm.ContactID;
                c.Town = bvm.Town;
                c.ZipCode = bvm.ZipCode;
                entry.Contact = c;

                db.Entries.Add(entry);
                db.Contacts.Add(c);
                db.SaveChanges();
                //TODO send email to adress.
                return RedirectToAction("Detail/" + entry.Id);
            }

            return View(bvm);
        }
Пример #2
0
 public ActionResult Edit(Entry entry)
 {
     if (ModelState.IsValid)
     {
         db.Entry(entry).State = EntityState.Modified;
         db.SaveChanges();
         return RedirectToAction("Index");
     }
     return View(entry);
 }