public async Task <IActionResult> Create(CreateFileRequestModel dto)
        {
            if (!ModelState.IsValid)
            {
                return(View(dto));
            }

            if (!CheckFileExtension(dto.PrimaryImage?.FileName) || !CheckFileExtension(dto.SecondaryImage?.FileName))
            {
                ViewData["Errors"] = new Error[]
                { new("Расширение файла должно быть .jpg, .jpeg или .png", "400") };
                return(View(dto));
            }

            var created = await _service.Create(User.GetId(), User.GetRole(), new AdvertDto()
            {
                Name               = dto.Name,
                RequestType        = dto.RequestType,
                ImpressingDateFrom = dto.ImpressingDateFrom,
                ImpressingDateTo   = dto.ImpressingDateTo,
                ImpressingTimeFrom = dto.ImpressingTimeFrom,
                ImpressingTimeTo   = dto.ImpressingTimeTo,
                ImpressingAlways   = dto.ImpressingAlways,
                IsVisible          = true
            }, dto.PrimaryImage.ToFile(), dto.SecondaryImage.ToFile());

            if (!created.Ok)
            {
                ViewData["Errors"] = created.Errors;
                return(View(dto));
            }


            return(RedirectToAction("Index"));
        }
        public void Post([FromBody] AdvertViewModel advert)
        {
            var user         = _userService.FindByName(User.Identity.Name);
            var mappedAdvert = MapOneModel(advert);

            mappedAdvert.AuthorId         = user.Id;
            mappedAdvert.InterestedUserId = null;
            _advertService.Create(mappedAdvert);
        }
        public IActionResult Create(AdvertViewModel model)
        {
            if (ModelState.IsValid)
            {
                model.SubmittedDate = DateTime.Now;
                model.Status        = EnumTypes.AdvertStatus.SUBMITTED.ToString();

                advertService.Create(mapper.Map <Advert>(model));
                advertService.Save();
                return(RedirectToAction("Index", "Classifieds"));
            }

            ViewBag.Categories    = CatSelectListItems(model.ParentID);
            ViewBag.SubCategories = SubCatSelectListItems(model.ParentID, model.CategoryID);

            return(View(model));
        }