Пример #1
0
        public void AddContact(string from, string to)
        {
            Contact contact = _context.Contact.Where(x => x.FromId == from && x.ToId == to).FirstOrDefault();

            if (contact == null)
            {
                _context.Contact.Add(new Contact
                {
                    FromId = from,
                    ToId   = to
                });

                _context.SaveChanges();
            }
        }
Пример #2
0
        public IActionResult Create(Book book)
        {
            try
            {
                _context.Book.Add(book);
                _context.SaveChanges();
                return(RedirectToAction("showBooks"));
            }

            catch
            {
                //return View();
            }

            return(RedirectToAction("Index"));

            //return View();
        }