public async Task <IActionResult> Edit(int id, [Bind("Id,ListOfMediaId,DictControlTypeId,StartDate,EndDate,StartDatePeriod,EndDatePeriod,LastName,FirstName,PatronicName,ActDateControl,NumberOfAct,DictMediaControlResultId,NumberOfWarning,WarningDate,WarningEndDate,DateOfPenalty,DocNumPenalty,PenaltySum,DateOfPenaltyPay,AnulmentDate,NumberOfAnulment,DateOfSuit,NumberOfSuit,DateOfSuitPerm,NumberOfSuitPerm,DictMediaSuitPermId,WarningRemovalDate")] ListOfControlMedia listOfControlMedia)
        {
            if (id != listOfControlMedia.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(listOfControlMedia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ListOfControlMediaExists(listOfControlMedia.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DictControlTypeId"]        = new SelectList(_context.DictControlType, "Id", "NameRus", listOfControlMedia.DictControlTypeId);
            ViewData["DictMediaControlResultId"] = new SelectList(_context.DictMediaControlResult, "Id", "NameRus", listOfControlMedia.DictMediaControlResultId);
            ViewData["DictMediaSuitPermId"]      = new SelectList(_context.DictMediaSuitPerm, "Id", "NameRus", listOfControlMedia.DictMediaSuitPermId);
            ViewData["ListOfMediaId"]            = new SelectList(_context.ListOfMedia, "Id", "NameRus", listOfControlMedia.ListOfMediaId);
            return(View(listOfControlMedia));
        }
        // GET: Media/ListOfControlMedias/Create
        public IActionResult Create()
        {
            ViewData["DictControlTypeId"]        = new SelectList(_context.DictControlType, "Id", "NameRus");
            ViewData["DictMediaControlResultId"] = new SelectList(_context.DictMediaControlResult, "Id", "NameRus");
            ViewData["DictMediaSuitPermId"]      = new SelectList(_context.DictMediaSuitPerm, "Id", "NameRus");
            ViewData["ListOfMediaId"]            = new SelectList(_context.ListOfMedia, "Id", "Name");

            string name = "0";

            if (HttpContext.Request.Cookies.ContainsKey("ListOfMediaId"))
            {
                name = HttpContext.Request.Cookies["ListOfMediaId"];
            }


            string uid = _httpContextAccessor.HttpContext.User.FindFirst(ClaimTypes.NameIdentifier).Value;

            ListOfControlMedia model = new ListOfControlMedia();

            model.ListOfMediaId     = int.Parse(name);
            model.CreateDate        = DateTime.Now;
            model.ApplicationUserId = uid;

            return(View(model));
        }
        public async Task <IActionResult> Create([Bind("Id,ListOfMediaId,DictControlTypeId,StartDate,EndDate,StartDatePeriod,EndDatePeriod,LastName,FirstName,PatronicName,ActDateControl,NumberOfAct,DictMediaControlResultId,NumberOfWarning,WarningDate,WarningEndDate,DateOfPenalty,DocNumPenalty,PenaltySum,DateOfPenaltyPay,AnulmentDate,NumberOfAnulment,DateOfSuit,NumberOfSuit,DateOfSuitPerm,NumberOfSuitPerm,DictMediaSuitPermId,WarningRemovalDate")] ListOfControlMedia listOfControlMedia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(listOfControlMedia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DictControlTypeId"]        = new SelectList(_context.DictControlType, "Id", "NameRus", listOfControlMedia.DictControlTypeId);
            ViewData["DictMediaControlResultId"] = new SelectList(_context.DictMediaControlResult, "Id", "NameRus", listOfControlMedia.DictMediaControlResultId);
            ViewData["DictMediaSuitPermId"]      = new SelectList(_context.DictMediaSuitPerm, "Id", "NameRus", listOfControlMedia.DictMediaSuitPermId);
            ViewData["ListOfMediaId"]            = new SelectList(_context.ListOfMedia, "Id", "NameRus", listOfControlMedia.ListOfMediaId);
            return(View(listOfControlMedia));
        }