public async Task <IActionResult> DeletePresentation(CompanyPresentation presentation) { _genericsRepo.Delete(presentation); if (await _genericsRepo.SaveAll()) { return(NoContent()); } return(BadRequest("Delete Failed!")); }
public async Task <IActionResult> UpdatePresentation(CompanyPresentation presentation) { var updatedPresentation = await _companyPresentationsService.UpdatePresentation(presentation); if (await _genericsRepo.SaveAll()) { return(Ok(updatedPresentation)); } return(BadRequest("Update Failed or the same presentation was sent")); }
public async Task <PresentationForUpdateDto> UpdatePresentation(CompanyPresentation presentation) { var currentPresentation = await _companyPresentationsRepo.GetPresentationById(presentation.Id); currentPresentation.Name = presentation.Name; currentPresentation.StartDate = presentation.StartDate.LocalDateTime; currentPresentation.EndDate = presentation.EndDate.LocalDateTime; currentPresentation.ClassId = presentation.ClassId; var mappedCourse = _mapper.Map <PresentationForUpdateDto>(currentPresentation); return(mappedCourse); }
public async Task <bool> CompanyPresentationExists(CompanyPresentation companyPresentation) { var presentations = await GetCompanyPresentationsForUser(); foreach (var presentation in presentations) { if (companyPresentation.StartDate == presentation.StartDate && companyPresentation.ClassId == presentation.ClassId) { return(true); } } return(false); }
public async Task <IActionResult> AddPresentation(CompanyPresentation presentation) { if (await _companyPresentationsService.CompanyPresentationExists(presentation)) { return(BadRequest("There is a presentation already at this hour or in this class!")); } _companyPresentationsService.AddCompanyPresentation(presentation); if (await _genericsRepo.SaveAll()) { return(NoContent()); } return(BadRequest("Something went wrong!")); }
public void AddCompanyPresentation(CompanyPresentation companyPresentation) { companyPresentation.StartDate = companyPresentation.StartDate.LocalDateTime; companyPresentation.EndDate = companyPresentation.EndDate.LocalDateTime; _genericsRepo.Add(companyPresentation); }