Пример #1
0
        public async Task <IActionResult> CreateOffer([FromBody] NewOfferModel offer)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var offerCreated = await _offerService.CreateOfferAsync(offer.Name, offer.Description, offer.RoleId);

            return(CreatedAtAction("GetOffer", new { id = offerCreated.OfferId }, offer));
        }
Пример #2
0
        public async Task <IActionResult> Post([FromForm] PostOfferDto offerDto)
        {
            var offer = _mapper.Map <Offer>(offerDto);

            var createdOffer = await _offerService.CreateOfferAsync(offer, offerDto.Files);

            var createdOfferDto = _mapper.Map <OfferDto>(createdOffer);

            createdOfferDto.Images = CreateUrlsToPhotos(createdOffer.Images);

            _emailService.SendActivateMessage(HttpContext.Request.GetDisplayUrl() + "activateOffer/" + createdOffer.Id);
            return(Ok(createdOfferDto));
        }
Пример #3
0
        public async Task CreateOffer_ShouldReturnOfferWithOverridenId()
        {
            // Arrange
            var oldId = "oldId";
            var offer = new Offer()
            {
                Id = oldId
            };

            _offerRepositoryMock.Add(Arg.Any <Offer>());

            _imageSaver.SaveImagesAsync(Arg.Any <IFormFileCollection>()).Returns(new List <string>());

            // Act
            var result = await _offerService.CreateOfferAsync(offer, null);

            // Assert
            result.Id.Should().NotBe(oldId);
        }