public IActionResult About() { var about = db.Abouts.ToList(); Models.Objects.About a = new Models.Objects.About(); if (about.Count == 0) { about = new List <Models.Objects.About>(); } else { a = about.OrderByDescending(o => o.Id).FirstOrDefault(); } var cont = db.Contacts.ToList(); Models.Objects.Contact c = new Models.Objects.Contact(); if (cont.Count != 0) { c = cont.OrderByDescending(c => c.Id).First(); } var aboutModel = new AboutModel() { Abouts = a, Categories = db.Categories.ToList(), Contacts = c }; return(View("About", aboutModel)); }
public IActionResult Contacts(string EmailInfo, string EmailMarketing, string PhoneInfo, string PhoneMarketing, string VKLink, string OKLink, string FacebookLink, string InstagramLink, string Address) { db.Contacts.Add(new Models.Objects.Contact() { EmailInfo = EmailInfo, EmailMarketing = EmailMarketing, PhoneInfo = PhoneInfo, PhoneMarketing = PhoneMarketing, VKLink = VKLink, OKLink = OKLink, FacebookLink = FacebookLink, InstagramLink = InstagramLink, Address = Address, LastDateEdit = DateTime.Now }); db.SaveChanges(); Models.Objects.Contact contacts = GetContact(); if (Auth()) { return(View("Contacts", contacts)); } else { return(View("Login")); } }
private Models.Objects.Contact GetContact() { var contacts = db.Contacts.ToList().LastOrDefault(); if (contacts == null) { contacts = new Models.Objects.Contact(); } return(contacts); }
public IActionResult Contacts() { if (Auth()) { Models.Objects.Contact contacts = GetContact(); return(View("Contacts", contacts)); } else { return(View("Login")); } }