Ejemplo n.º 1
0
        public static BlackListViewModel Create(Blacklist item)
        {
            var model = new BlackListViewModel
            {
                Id          = item.Id,
                Description = item.Description,
                PhoneNumber = item.PhoneNumber
            };

            return(model);
        }
Ejemplo n.º 2
0
        public static BlackListViewModel Create(Blacklist item)
        {
            var model = new BlackListViewModel
            {
                Id = item.Id,
                Description = item.Description,
                PhoneNumber = item.PhoneNumber
            };

            return model;
        }
Ejemplo n.º 3
0
        public IActionResult Create(BlackListViewModel model)
        {
            if (ModelState.IsValid)
            {
                var item = new Blacklist
                {
                    Description = model.Description,
                    PhoneNumber = model.PhoneNumber,
                    User = CurrentUser
                };
                _context.BlackLists.Add(item);
                _context.SaveChanges();

                var editUrl = Url.Action("Edit", new { id = item.Id });
                SuccessMessage($"<a href=\"{editUrl}\">Запись</a> была создана");

                return RedirectToAction("Index");
            }
            
            return View(model);
        }