public ActionResult Save(GigDto gigDto) { if (!ModelState.IsValid) { var viewModel = new GigFormViewModel { GigDto = gigDto, GenreDtos = _unitOfWork.GenresRepository.GetGenres().Select(Mapper.Map <Genre, GenreDto>) }; return(View("GigForm", viewModel)); } if (gigDto.Id == 0) { AddGig(gigDto); } else { UpdateGig(gigDto); } _unitOfWork.Save(); return(RedirectToAction("Mine", "Gigs")); }
public async Task <ActionResult <GigDto> > Put(int gigId, GigDto dto) { try { var oldGig = await _eventRepository.GetGig(gigId); if (oldGig == null) { return(NotFound($"Could not find gig with id {gigId}")); } var newGig = _mapper.Map(dto, oldGig); _eventRepository.Update(newGig); if (await _eventRepository.Save()) { return(NoContent()); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
private void AddGig(GigDto gigDto) { var gig = Mapper.Map <GigDto, Gig>(gigDto); gig.ArtistId = User.Identity.GetUserId(); _unitOfWork.GigsRepository.Add(gig); }
private async Task DeleteProductAsync(GigDto gig) { var confirmMessage = L["GigDeletionConfirmationMessage", gig.Title]; if (!await Message.Confirm(confirmMessage)) { return; } await GigAppService.DeleteAsync(gig.Id); await GetProductsAsync(); }
public void Modify(GigDto gigDto) { var originalDateTime = DateTime; var originalVenue = Venue; Mapper.Map(gigDto, this); if (originalDateTime == DateTime && originalVenue == Venue) { return; } var notification = Notification.GigUpdated(this, originalDateTime, originalVenue); Notify(notification); }
private async Task HandlePublish(GigDto gig) { GigDto resultGig = null; if (gig.IsPublished) { resultGig = await GigAppService.UnpublishAsync(gig.Id); } else { resultGig = await GigAppService.PublishAsync(gig.Id); } var message = resultGig.IsPublished ? "Published " : "UnPublished"; await Message.Success($"Product successfully {message}"); await GetProductsAsync(); }
public async Task <ActionResult <GigDto> > Post(GigDto dto) { try { var mappedEntity = _mapper.Map <Gig>(dto); _eventRepository.Add(mappedEntity); if (await _eventRepository.Save()) { var location = _linkGenerator.GetPathByAction("Get", "Gigs", new { mappedEntity.GigId }); return(Created(location, _mapper.Map <GigDto>(mappedEntity))); } } catch (Exception) { return(this.StatusCode(StatusCodes.Status500InternalServerError, "Database Failure")); } return(BadRequest()); }
public async Task <ActionResult <GigDto> > Post([FromBody] GigDto dto) { try { var mappedEntity = _mapper.Map <Gig>(dto); _eventRepository.Add(mappedEntity); if (await _eventRepository.Save()) { var location = Url.Action(action: "GetGig", new { gigId = mappedEntity.GigId }); return(Created(location, _mapper.Map <GigDto>(mappedEntity))); } } catch (Exception ex) { return(this.StatusCode(StatusCodes.Status500InternalServerError, ex.Message)); } return(BadRequest()); }
public IHttpActionResult Cancel(GigDto gigDto) { var userId = User.Identity.GetUserId(); var gig = _unitOfWork.GigRepository.GetGigWithAttendee(gigDto.GigId); if (gig.IsCanceled) { return(NotFound()); } if (gig.ArtistId != userId) { return(Unauthorized()); } gig.Cancel(); _unitOfWork.Complete(); return(Ok()); }
private void OpenGigForm(GigDto gig) { NavigationManager.NavigateTo("/manage/gigs/editor/" + gig.Id); }
public IHttpActionResult PurchasePackage(GigDto gigDto) { var userId = User.Identity.GetUserId(); var buyer = unitOfWork.ApplicationUserRepository.GetUser(userId); if (buyer == null) { return(NotFound()); } var gig = unitOfWork.GigsRepository.GetGigForPurchase(gigDto.ID); if (gig == null) { return(NotFound()); } var auroraWallet = unitOfWork.AuroraWalletRepository.GetAuroraWallet(); if (auroraWallet == null) { return(NotFound()); } if (gigDto.BasicPackageID != null && gigDto.AdvancedPackageID == null && gigDto.PremiumPackageID == null) { //BRING THE PACKAGE FOR PURCHASE var basicPackage = unitOfWork.BasicPackageRepository.GetBasicPackagePurchase(gigDto.BasicPackageID); // CHECK IF THE PACKAGE EXIST if (basicPackage == null) { return(NotFound()); } else { // CHECK IF THE PAYMENT CAN BE DONE try { basicPackage.SellPackage(buyer, gig.User, auroraWallet); } catch (Exception) { return(NotFound()); } } } else if (gigDto.BasicPackageID == null && gigDto.AdvancedPackageID != null && gigDto.PremiumPackageID == null) { //BRING THE PACKAGE FOR PURCHASE var advancedPackage = unitOfWork.AdvancedPackageRepository.GetAdvancedPackagePurchase(gigDto.AdvancedPackageID); // CHECK IF THE PACKAGE EXIST if (advancedPackage == null) { return(NotFound()); } else { // CHECK IF THE PAYMENT CAN BE DONE try { advancedPackage.SellPackage(buyer, gig.User, auroraWallet); } catch (Exception) { return(NotFound()); } } } else if (gigDto.BasicPackageID == null && gigDto.AdvancedPackageID == null && gigDto.PremiumPackageID != null) { //BRING THE PACKAGE FOR PURCHASE var premiumPackage = unitOfWork.PremiumPackageRepository.GetPremiumPackagePurchase(gigDto.PremiumPackageID); // CHECK IF THE PACKAGE EXIST if (premiumPackage == null) { return(NotFound()); } else { // CHECK IF THE PAYMENT CAN BE DONE try { premiumPackage.SellPackage(buyer, gig.User, auroraWallet); } catch (Exception) { return(NotFound()); } } } else { return(BadRequest()); } unitOfWork.Complete(); return(Ok()); }
private void HandleGigClicked(GigDto gig) { NavigationManager.NavigateTo("/gigs/detail/" + gig.Id); }
private void UpdateGig(GigDto gigDto) { var gig = _unitOfWork.GigsRepository.GetGigIncludeAttendees(gigDto.Id); gig.Modify(gigDto); }