public async Task <IEnumerable <ExhibitDomainModel> > GetAllExhibitsForSpecificExhibitions(int id) { var data = await _exhibitionsRepository.GetByIdAsync(id); if (data == null) { return(null); } var data1 = await _exhibitRepository.GetAllExhibitsForSpecificExhibitions(id); if (data1 == null) { return(null); } List <ExhibitDomainModel> list = new List <ExhibitDomainModel>(); ExhibitDomainModel exhibitDomainModel; foreach (var item in data1) { exhibitDomainModel = new ExhibitDomainModel { ExhibitionId = item.ExhibitionId, Name = item.ExhibitName, Year = item.Year, ExhibitId = item.ExhibitId, PicturePath = item.PicturePath, AuditoriumId = item.AuditoriumId }; list.Add(exhibitDomainModel); } return(list); }
public async Task <ExhibitionResultModel> DeleteExhibition(int id) { var listOfExhibitions = await _exhibitionRepository.GetAll(); if (listOfExhibitions == null) { return(new ExhibitionResultModel { ErrorMessage = Messages.EXHIBITIONS_LIST_IS_EMPTY, IsSuccessful = false, Exhibition = null }); } else { var existing = await _exhibitionRepository.GetByIdAsync(id); if (existing == null) { return(new ExhibitionResultModel { ErrorMessage = Messages.EXHIBITION_DOES_NOT_EXIST, IsSuccessful = false, Exhibition = null }); } //exhibition in the future if (existing.StartTime > DateTime.Now) { return(new ExhibitionResultModel { ErrorMessage = Messages.EXHIBITION_IN_THE_FUTURE, IsSuccessful = false, Exhibition = null }); } //The exhibition began but wasn't finished if ((existing.EndTime == DateTime.Now) || (existing.EndTime > DateTime.Now)) { return(new ExhibitionResultModel { ErrorMessage = Messages.EXHIBITION_IS_NOT_OVER, IsSuccessful = false, Exhibition = null }); } var deletedExhibition = _exhibitionRepository.Delete(id); ExhibitionResultModel result = new ExhibitionResultModel { ErrorMessage = null, IsSuccessful = true, Exhibition = new ExhibitionDomainModel { ExhibitionId = deletedExhibition.ExhibitionId, ExhibitionName = deletedExhibition.ExhibitionName, AuditoriumId = deletedExhibition.AuditoriumId, TypeOfExhibition = deletedExhibition.TypeOfExhibition, StartTime = deletedExhibition.StartTime, EndTime = deletedExhibition.EndTime } }; return(result); } }