public async Task <IActionResult> CreateConference([FromBody] Conference input) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } var conference = new Conference { Name = input.Name }; _db.Conferences.Add(conference); await _db.SaveChangesAsync(); var result = new ConferenceDto { ID = conference.ID, Name = conference.Name, //Sessions = ??, //Tracks = ?? //Sessions = ?? }; return(CreatedAtAction(nameof(GetConference), new { id = conference.ID }, result)); }
public Task <int> Add(ConferenceDto conferenceDto) { var entity = ConferenceAdapter.FromConferenceDtoToConference(conferenceDto); _dbContext.Conferences.Add(entity); return(_dbContext.SaveChangesAsync()); }
public async Task <IActionResult> UpdateConference([FromRoute] int id, [FromBody] Conference input) { var conference = await _db.FindAsync <Conference>(id); if (conference == null) { return(NotFound()); } if (!ModelState.IsValid) { return(BadRequest(ModelState)); } conference.Name = input.Name; await _db.SaveChangesAsync(); var result = new ConferenceDto { ID = conference.ID, Name = conference.Name, //Sessions = ??, //Tracks = ?? //Sessions = ?? }; return(Ok(result)); }
public IActionResult Update([FromBody] ConferenceDto conference) { var id = Convert.ToInt32(User.FindFirst(ClaimTypes.NameIdentifier).Value); _conferenceService.Update(id, conference); return(Ok()); }
public async Task <ConferenceDto> GetRemoteConference(Priority priority, string slug) { ConferenceDto conference = null; Task <ConferenceDto> getConferenceTask; switch (priority) { case Priority.Background: getConferenceTask = _apiService.Background.GetConference(slug); break; case Priority.UserInitiated: getConferenceTask = _apiService.UserInitiated.GetConference(slug); break; case Priority.Speculative: getConferenceTask = _apiService.Speculative.GetConference(slug); break; default: getConferenceTask = _apiService.UserInitiated.GetConference(slug); break; } if (CrossConnectivity.Current.IsConnected) { conference = await Policy .Handle <Exception>() .RetryAsync(retryCount: 5) .ExecuteAsync(async() => await getConferenceTask); } return(conference); }
public async Task <IActionResult> UpdateAsync([FromRoute] Guid id, [FromBody] ConferenceDto dto) { dto.Id = id; await _conferencesService.UpdateAsync(dto); return(NoContent()); }
public IActionResult AddConference(ConferenceDto conferenceDto) { var entity = new ConferenceEntity(); _eventMapper.FillConferenceEntityWithDto(conferenceDto, entity); _eventRepository.AddEvent(entity); return(CreatedAtAction("GetEvent", new { eventId = entity.Id }, entity)); }
public async Task LoadConferencesAsync(LoadRequest loadRequest) { this.AreConferencesLoading = true; //_messenger.Publish (new ConferencesLoading (this)); List <Conference> conferences = await _databaseService.LoadConferencesAsync(); if (conferences == null || !conferences.Any() || loadRequest == LoadRequest.Refresh) { var user = await _databaseService.LoadCurrentUserAsync(); string userName = ""; if (user != null) { userName = user.UserName; } await _databaseService.DeleteAllConferencesAsync(); var conferenceDtos = await _conferenceService.LoadConferencesAsync(userName); if (conferenceDtos != null) { foreach (var conferenceDto in conferenceDtos) { ConferenceDto dto = conferenceDto; var conference = await TaskEx.Run(() => Mapper.Map <Conference>(dto)); await _databaseService.SaveConferenceAsync(conference); foreach (var sessionDto in conferenceDto.Sessions) { SessionDto dto1 = sessionDto; var session = await TaskEx.Run(() => Mapper.Map <Session>(dto1)); session.ConferenceId = conference.Id; await _databaseService.SaveSessionAsync(session); foreach (var speakerDto in sessionDto.Speakers) { SpeakerDto speakerDto1 = speakerDto; var speaker = await TaskEx.Run(() => Mapper.Map <Speaker>(speakerDto1)); speaker.SessionId = session.Id; await _databaseService.SaveSpeakerAsync(speaker); } } } } conferences = await _databaseService.LoadConferencesAsync(); } this.AreConferencesLoading = false; //_messenger.Publish(new ConferencesLoaded(this)); this.Conferences = conferences; }
public static Conference FromConferenceDtoToConference(ConferenceDto conferenceDto) { return(new Conference { Location = conferenceDto.Location, Name = conferenceDto.Name, Start = conferenceDto.Start }); }
public async Task <IActionResult> Add(ConferenceDto conferenceDto) { if (ModelState.IsValid) { await _conferenceRepository.Add(conferenceDto); } return(RedirectToAction("Index")); }
public async Task UpdateAsync(ConferenceDto dto) { var conference = await _conferenceRepository.GetAsync(dto.Id); if (conference is null) { throw new ConferenceNotFoundException(dto.Id); } conference.Name = dto.Name; await _conferenceRepository.UnitOfWork.SaveChangesAsync(); }
public void Update(int userId, ConferenceDto conferenceDto) { if (CheckUserUpdatePermission(userId, conferenceDto.Id)) { var conference = _mapper.Map <Conference>(conferenceDto); _conferenceRepository.Update(conference); } else { throw new NotEnoughRightsException(); } }
public int Add(int userId, ConferenceDto conferenceDto) { if (CheckUserPermission(userId)) { var conference = _mapper.Map <Conference>(conferenceDto); //foreach (var admin in conferenceDto.Admins)//.GroupBy(s => s.Id).FirstOrDefault() //{ // conference.AdminOfConferences.Add(new AdminOfConference() { UserId = admin.Id}); //} return(_conferenceRepository.Add(conference)); } throw new NotEnoughRightsException(); }
public async Task <IActionResult> PutConference(int id, ConferenceDto input) { var conference = await _db.FindAsync <Data.Conference>(id); if (conference == null) { return(NotFound()); } conference.Name = input.Name; await _db.SaveChangesAsync(); return(NoContent()); }
public async Task <ActionResult <ConferenceResponse> > CreateConference(ConferenceDto input) { var conference = new Data.Conference { Name = input.Name }; _db.Conferences.Add(conference); await _db.SaveChangesAsync(); var result = new ConferenceResponse { ID = conference.ID, Name = conference.Name }; return(CreatedAtAction(nameof(GetConference), new { id = conference.ID }, result)); }
public async Task <IActionResult> GetConference([FromRoute] int id) { var conference = await _db.FindAsync <Conference>(id); if (conference == null) { return(NotFound()); } var result = new ConferenceDto { ID = conference.ID, Name = conference.Name, //Sessions = ??, //Tracks = ?? //Sessions = ?? }; return(Ok(result)); }
public async Task GetConference(string slug) { var fixture = new Fixture(); var tekconfApi = new Mock <ITekConfApi>(); var expectedName = fixture.Create <string>(); var expectedConference = new ConferenceDto { Slug = slug, Name = expectedName }; tekconfApi.Setup(x => x.GetConference(slug)).ReturnsAsync(expectedConference); var api = new Mock <IApiService>(); var service = new ConferencesService(api.Object); var conference = await service.GetConference(Priority.UserInitiated, slug); conference.ShouldNotBeNull(); conference.Name.ShouldEqual(expectedName); tekconfApi.Verify(x => x.GetConference(slug), Times.Exactly(1)); }
public void FillConferenceEntityWithDto(ConferenceDto dto, ConferenceEntity entity) { FillEventEntityWithDto(dto, entity); entity.BadgeCosts = dto.BadgeCosts; entity.CateringCosts = dto.CateringCosts; }