示例#1
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (!PageContext.ModelState.IsValid)
            {
                var validator   = new OfferViewModelValidator();
                var createCheck = validator.Validate(Offer);
                createCheck.AddToModelState(ModelState, nameof(Offer));

                return(Page());
            }

            var company = _offerService.GetUsersCompanyAsync(UserId);

            var offer = new Offer
            {
                Name        = Offer.Name,
                Description = Offer.Description,
                Price       = Offer.Price,
                OfferTypeId = SelectedType,
                CompanyId   = company.Result.Id
            };

            await _offerService.AddAsync(offer);

            return(Redirect("/"));
        }