Beispiel #1
0
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                LoadEnums();
                return(Page());
            }

            Contact.DateContacted = TodaysDate;
            _contactData.Add(Contact);
            _contactData.Commit();
            LoadEnums();

            return(Page());
        }
Beispiel #2
0
 public IActionResult OnPost()
 {
     if (!ModelState.IsValid)
     {
         ContactTypes = htmlHelper.GetEnumSelectList <ContactType>();
         return(Page());
     }
     if (Contact.Id > 0)
     {
         contactData.Update(Contact);
     }
     else
     {
         contactData.Add(Contact);
     }
     contactData.Commit();
     TempData["Message"] = "Contact Saved!";
     return(RedirectToPage("./Detail", new { contactId = Contact.Id }));
 }
Beispiel #3
0
        //[ValidateAntiForgeryToken]
        public IActionResult Reservierung(ContactDataDetailModel contactDataDetailModel)
        {
            if (ModelState.IsValid && !CheckIfContactDataAlreadyExists(contactDataDetailModel))
            {
                var contactData = new ContactData()
                {
                    Id             = contactDataDetailModel.ID,
                    FirstName      = contactDataDetailModel.FirstName,
                    LastName       = contactDataDetailModel.LastName,
                    PLZ            = contactDataDetailModel.PLZ,
                    EMail          = contactDataDetailModel.Email,
                    TelephonNumber = contactDataDetailModel.Telephonnumber
                };


                _contactData.Add(contactData);
                return(RedirectToAction("Index", "Home"));
            }
            contactDataDetailModel.isContactDataAlreadyExisting = true;
            return(View(contactDataDetailModel));
        }
        public IActionResult OnPost()
        {
            if (!ModelState.IsValid)
            {
                Nationalities = htmlHelper.GetEnumSelectList <NationalityType>();
                return(Page());
            }
            if (contact.Id > 0)
            {
                contactData.Update(contact);
                TempData["Message"] = "Contact has been updated.";
            }
            else
            {
                contactData.Add(contact);
                TempData["Message"] = "New Contact has been created.";
            }

            contactData.Commit();
            return(RedirectToPage("./Detail", new { contactId = contact.Id }));
        }