public void Book(Book book) { if (!_context.Books.Any(x => x.Email == book.Email && x.Name == book.Name && x.BookDate == book.BookDate && x.Phone == book.Phone) && ModelState.IsValid) { book.Date = DateTime.Now; _context.Books.Add(book); _context.SaveChanges(); } }
public void SendMessage(ContactMessage msg) { if (!_context.ContactMessages.Any(x => x.Email == msg.Email && x.Subject == msg.Subject && x.Message == msg.Message && x.Phone == msg.Phone) && ModelState.IsValid) { msg.Date = DateTime.Now; _context.ContactMessages.Add(msg); _context.SaveChanges(); } }
public IActionResult Order(List <byte> orders) { for (int i = 0; i < orders.Count; i++) { _context.FoodCategories.Where(x => x.Order == orders[i]).FirstOrDefault().Order = (byte)(i + 1); } _context.SaveChanges(); _categories = _context.FoodCategories.ToList(); return(RedirectToAction("Index", "Menu", _categories)); }