public void NotVisit(int id, string userId) { EventVisitors visitor = Database.EventVisitorsRepository.FindEventById(id, userId); Database.EventVisitorsRepository.Delete(visitor); Database.SaveAsync(); }
public void Visit(int id, string userId) { EventVisitors visitor = Database.EventVisitorsRepository.FindEventById(id, userId); if (visitor == null) { User user = Database.ProfileManager.FindById(userId).User; Event even = Database.EventRepository.GetById(id); Database.EventVisitorsRepository.Add(new EventVisitors { User = user, Event = even }); Database.SaveAsync(); } }
public EventsDTO GetEvent(Event even, string id) { Location l = Database.LocationRepository.GetById(even.LocationId); Photo photo = Database.PhotoRepository.GetById(Database.EventPhotoRepository.FindByEventId(even.Id).PhotoId); List <string> categories = new List <string>(); foreach (var x in Database.EventCategoryRepository.FindByEventId(even.Id)) { categories.Add(Database.CategoryRepository.GetById(x.CategoryId).Name); } int flag = 1; EventVisitors visitor = Database.EventVisitorsRepository.FindEventById(even.Id, id); if (visitor == null) { flag = -1; } else if (id == even.OwnerId) { flag = 0; } EventsDTO eventsDto = new EventsDTO { Id = even.Id, Title = even.Title, DateFrom = even.DateFrom, DateTo = even.DateTo, Description = even.Description, OwnerId = even.OwnerId, city_state = l.City, country = l.Country, url = photo.Url, Categories = categories, Ifigo = flag }; return(eventsDto); }