private Task <bool> Exist(EventDb db, EventEntity <TPrimaryKey> entity) { switch (entity.ActorId) { case long id: { var paramId = id; var table = db.Table <long>().TableName(this.tableName); return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync()); }; case string id: { var paramId = id; var table = db.Table <string>().TableName(this.tableName); return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync()); }; case Guid id: { var paramId = id; var table = db.Table <Guid>().TableName(this.tableName); return(table.Where(o => o.ActorId == paramId && o.Name == entity.Name && o.FlowId == entity.FlowId).AnyAsync()); }; default: throw new ArgumentOutOfRangeException(typeof(TPrimaryKey).FullName); } }
public EventViewModel(EventDb @event) { Id = @event.Id; Name = @event.Name; ImageUrl = @event?.ImageUrl; Description = @event.Description; }
private void SetSpeakerContext(EventDb eventToModifier) { var speakersSelected = Speakers.Where(x => x.IsSpeaker).ToList(); var speakersToAddToDb = speakersSelected.Where(x => !_context.Speakers.Any(s => x.Id == s.Id)).ToList(); speakersToAddToDb?.ForEach(x => { _context.Speakers.Add(new Speaker { Id = x.Id }); }); var speakerToAddFromEvent = speakersSelected.Where(x => !eventToModifier.Speakers.Any(s => s.SpeakerId == x.Id)) .ToList(); speakerToAddFromEvent?.ForEach(x => { eventToModifier.Speakers.Add(new SpeakerEvent { SpeakerId = x.Id, Event = eventToModifier }); }); eventToModifier.Speakers.Where(x => !speakersSelected.Any(s => s.Id == x.SpeakerId)) .ToList() ?.ForEach(x => eventToModifier.Speakers.Remove(x)); }
private void SetSponsorContext(EventDb eventToModifier) { var sponsorsSelected = Sponsors.Where(x => x.Selected).ToList(); var sponsorsToAddToDb = sponsorsSelected.Where(x => !_context.Sponsors.Any(s => x.Name == s.Name)).ToList(); sponsorsToAddToDb?.ForEach(x => { _context.Sponsors.Add(new SponsorDb { Name = x.Name, LogoUrl = x.LogoUrlHigh, Id = x.Name }); }); var sponsorsToAddFromEvent = sponsorsSelected.Where(x => !eventToModifier.Sponsors.Any(s => s.Sponsor.Name == x.Name)) .ToList(); sponsorsToAddFromEvent?.ForEach(x => { eventToModifier.Sponsors.Add(new SponsorEvent { SponsorId = x.Name, Event = eventToModifier }); }); eventToModifier.Sponsors.Where(x => !sponsorsSelected.Any(s => s.Name == x.SponsorId)) .ToList() ?.ForEach(x => eventToModifier.Sponsors.Remove(x)); }
private Event FromEventDbToEvent(EventDb eventDb) { var customizations = new Customizations( eventDb.Comment, eventDb.GeotagLatitude, eventDb.GeotagLongitude, eventDb.PhotoUrl, eventDb.Rating, eventDb.Scale); var @event = new Event(eventDb.Id, eventDb.CreatedAt, eventDb.TrackId, customizations); return(@event); }
public EventVewModel Map(EventDb entity) { var games = entity.Games.Select(Map); return new EventVewModel { Id = entity.EntityId, Minor = entity.Minor, Group = entity.Group, Name = entity.Name, StartDate = entity.StartDate, EndDate = entity.EndDate, Games = games }; }
private EventDb FromEventToEventDb(Event @event) { var newEventDb = new EventDb( @event.Id, @event.CreatedAt, @event.TrackId, @event.Customization.Scale?.Value, @event.Customization.Rating?.Value, @event.Customization.Photo?.Value, @event.Customization.Geotag?.Latitude, @event.Customization.Geotag?.Longitude, @event.Customization.Comment?.Value); return(newEventDb); }
public List <ServiceItemVm> GetAllServices() { var source = new List <ServiceItemVm>(); var dt = EventDb.GetAllServices(); foreach (DataRow row in dt.Rows) { var item = new ServiceItemVm(); item.Id = (int)row["Id"]; item.Name = (string)row["Name"]; item.CostPerHour = (decimal)row["CostPerHour"]; item.ServiceType = (string)row["ServiceType"]; source.Add(item); } return(source); }
public List <TypeVm> GetAllEventTypes() { var eventTypes = new List <TypeVm>(); DataTable dt = EventDb.GetAllEventTypes(); foreach (DataRow row in dt.Rows) { var type = new TypeVm(); type.Id = (int)row["Id"]; type.Name = (string)row["Name"]; eventTypes.Add(type); } return(eventTypes); }
public async Task <IActionResult> OnPostAsync(string id) { if (!ModelState.IsValid) { return(Page()); } var eventToModifier = _context.Events.Include(x => x.Speakers) .Include(x => x.Sponsors) .ThenInclude(s => s.Sponsor) .FirstOrDefault(x => x.Id == Event.Id); if (eventToModifier == null) { eventToModifier = new EventDb(Event); _context.Events.Add(eventToModifier); } SetSpeakerContext(eventToModifier); SetSponsorContext(eventToModifier); await _context.SaveChangesAsync(); return(RedirectToPage("/Events/List")); }
//public List<int> ServicesIds { get; set; } public List <EventItemVm> GetAllEvents() { var events = new List <EventItemVm>(); DataTable dt = EventDb.GetAllEvents(); foreach (DataRow row in dt.Rows) { var item = new EventItemVm(); item.Id = (int)row["Id"]; item.Start = (DateTime)row["Start"]; item.End = (DateTime)row["End"]; item.EventType = (string)row["EventType"]; item.Place = (string)row["Place"]; item.UserName = (string)row["UserName"]; item.ImageUrl = row.IsNull("ImageUrl") ? string.Empty : (string)row["ImageUrl"]; item.Comment = row.IsNull("Comment") ? string.Empty : (string)row["Comment"]; events.Add(item); } return(events); }
private LeagueInfoEventViewModel MapEvent(EventDb eventDb, IEnumerable<TeamDb> teams) { var dictionary = teams.ToDictionary(x => x.EntityId, x => x); var teamValues = eventDb.Games .Select(x => dictionary[x.HomeTeamId].Name + " - " + dictionary[x.GuestTeamId].Name); return new LeagueInfoEventViewModel { Name = eventDb.Name, Date = eventDb.StartDate, Teams = teamValues }; }
public EventBs() { objDb = new EventDb(); }
public void Create(EventVm vm) { EventDb.Create(vm.Start, vm.End, vm.EventTypeId, vm.PlaceId, vm.UserId, vm.ImageUrl, vm.ServicesIds, vm.Comment); }