Exemple #1
0
        public async Task <IActionResult> Create(VenueViewModel venue)
        {
            ModelState.Remove("Id");

            if (ModelState.IsValid)
            {
                var dbVenue = new Venue();
                dbVenue.Id         = Guid.NewGuid();
                dbVenue.Name       = venue.Name;
                dbVenue.Address    = venue.Address;
                dbVenue.City       = venue.City;
                dbVenue.Email      = venue.Email;
                dbVenue.Telephone  = venue.Telephone;
                dbVenue.Capacity   = venue.Capacity;
                dbVenue.TimeOpens  = venue.Open;
                dbVenue.TimeCloses = venue.Close;

                try {
                    var userDetails = await GetUserIdAsync();

                    dbVenue.OwnerUserId = userDetails.Id;

                    _venueService.CreateVenue(dbVenue);

                    return(RedirectToAction(nameof(Index)));
                }
                catch (Exception ex) {
                    this._logger.LogError(ex.StackTrace);
                    ModelState.AddModelError("GeneralError", ex.Message);
                    return(View(venue));
                }
            }
            return(View(venue));
        }
        public void CreateVenueShouldCallRepository()
        {
            VenueDto venue = new VenueDto();
            m_VenueRepositoryMock = new Mock<IVenueRepository>();
            m_VenueService = new VenueService(m_VenueRepositoryMock.Object);

            m_VenueService.CreateVenue(venue);

            m_VenueRepositoryMock.Verify(x => x.Persist(It.IsAny<Venue>()), Times.Once);
        }
 public void Post(Venue venue)
 {
     try
     {
         _venueService.CreateVenue(venue);
     }
     catch (Exception ex)
     {
         _logger.Log(LogLevel.Error, ex, "Something bad happened");
     }
 }
Exemple #4
0
        public async Task <ActionResult <BaseResponseDto <VenueDto> > > AddVenue(Venue venue)
        {
            BaseResponseDto <VenueDto> newVenue = await _venueService.CreateVenue(venue);

            if (!newVenue.HasError || newVenue.Data != null)
            {
                return(Ok(newVenue.Data));
            }
            else if (!newVenue.HasError || newVenue.Data == null)
            {
                return(NotFound());
            }
            else
            {
                return(BadRequest(newVenue.Errors));
            }
        }
Exemple #5
0
        public ActionResult Save(VenueViewModel venueViewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View("VenueForm", venueViewModel));
            }

            if (venueViewModel.Venue.Id == 0)
            {
                _venueService.CreateVenue(venueViewModel);
            }
            else
            {
                _venueService.EditVenue(venueViewModel, venueViewModel.Venue.Id);
            }

            return(RedirectToAction("Index", "Venues"));
        }
Exemple #6
0
        public async Task <IActionResult> Create(VenueModel model)
        {
            try
            {
                if (!ModelState.IsValid)
                {
                    return(BadRequest(GetModelStateErrors(ModelState)));
                }

                var response = await _venueService.CreateVenue(model);

                if (response.ResponseCode != ResponseCode.Ok)
                {
                    return(Ok(WebApiResponses <VenueModel> .ErrorOccured(response.Message)));
                }
                return(Ok(WebApiResponses <VenueModel> .Successful(response.ResponseData)));
            }
            catch (Exception ex)
            {
                Log.Error(ex);
                return(Ok(WebApiResponses <VenueModel> .ErrorOccured(ex.Message)));
            }
        }
Exemple #7
0
 public int Execute()
 {
     return(_service.CreateVenue(_command.Venue));
 }
Exemple #8
0
 public void CreateVenue_InputVenueIsNull_Throw()
 {
     Assert.Throws <NullReferenceException>(() => srv.CreateVenue(null));
 }