public void APIAdd(Sighting passedSighting) { if (!DoesSightingPreExist(passedSighting)) { Sighting sighting = new Sighting(); sighting.Longitude = passedSighting.Longitude; sighting.Latitude = passedSighting.Latitude; if (IsItemOnSameLocation(passedSighting)) { RandomiseLocation(passedSighting); } sighting.AspNetUserId = "473a991e-b5f9-4c19-b34e-255af548fc90"; sighting.Type = passedSighting.Type; sighting.Rarity = passedSighting.Rarity; sighting.PokeMon = passedSighting.PokeMon; sighting.TimeOfDay = passedSighting.TimeOfDay; sighting.Notes = passedSighting.Notes; db.Sightings.Add(sighting); db.SaveChanges(); Vote vote = new Vote(); vote.SightingId = sighting.SightingId; vote.AspNetUserId = "473a991e-b5f9-4c19-b34e-255af548fc90"; vote.Action = VoteAction.Up; db.Votes.Add(vote); db.SaveChanges(); } }
public bool CreateBird(BirdCreate model) { var entity = new Bird() { Name = model.Name, MainColor = model.MainColor, SecondColor = model.SecondColor }; var sighting = new Sighting() { SpotterID = _userId.ToString(), Bird = entity, TimeSeen = DateTimeOffset.Now }; using (var ctx = new ApplicationDbContext()) { ctx.Birds.Add(entity); ctx.Sightings.Add(sighting); return(ctx.SaveChanges() == 2); } }
public void Handle(FavouriteUpdateCommand command) { Check.RequireNotNull(command, "command"); var user = _documentSession.Load <User>(command.UserId); var favourites = _documentSession.Load <Favourites>(user.Favourites.Id); Sighting sighting = null; if (command.SightingId.ToLower().StartsWith("observation")) { sighting = _documentSession.Load <Observation>(command.SightingId); } else { sighting = _documentSession.Load <Record>(command.SightingId); } sighting.AddToFavourites( favourites, user, DateTime.UtcNow); _documentSession.Store(sighting); _documentSession.SaveChanges(); }
public object MakeUpdateIdentification(Sighting sighting, User user, int identificationId) { var identification = sighting.Identifications.Single(x => x.SequentialId == identificationId); dynamic viewModel = new ExpandoObject(); viewModel.Id = identificationId; viewModel.SightingId = sighting.Id; viewModel.IdentificationComments = identification.Comments; viewModel.Category = identification.Category; viewModel.Name = identification.Name; viewModel.RankName = identification.RankName; viewModel.RankType = identification.RankType; viewModel.IsCustomIdentification = identification.IsCustomIdentification; viewModel.AllCommonNames = identification.AllCommonNames; viewModel.Taxonomy = identification.Taxonomy; viewModel.Kingdom = identification.TryGetRankName("kingdom"); viewModel.Phylum = identification.TryGetRankName("phylum"); viewModel.Class = identification.TryGetRankName("class"); viewModel.Order = identification.TryGetRankName("order"); viewModel.Family = identification.TryGetRankName("family"); viewModel.Genus = identification.TryGetRankName("genus"); viewModel.Species = identification.TryGetRankName("species"); viewModel.Subspecies = identification.TryGetRankName("subspecies"); viewModel.CommonGroupNames = identification.CommonGroupNames.ToList(); viewModel.CommonNames = identification.CommonNames.ToList(); viewModel.Synonyms = identification.Synonyms.ToList(); return(viewModel); }
/// <summary> /// Delete the species with the specified name /// </summary> /// <param name="name"></param> public void Delete(string name) { // Get the species and make sure it exists name = _textInfo.ToTitleCase(name.CleanString()); Species species = Get(l => l.Name == name); if (species == null) { string message = $"Species '{name}' does not exist"; throw new SpeciesDoesNotExistException(message); } // Check the species isn't used in any sightings Sighting sighting = _factory.Context .Sightings .FirstOrDefault(s => s.SpeciesId == species.Id); if (sighting != null) { string message = $"Cannot delete species '{name}' while it is referenced in sightings"; throw new SpeciesIsInUseException(message); } // Delete the location _factory.Context.Species.Remove(species); _factory.Context.SaveChanges(); }
public void Post([FromBody] Sighting sighting) { GMPRestApi.Models.Data.GMPMissingPersonEntities entities = new GMPRestApi.Models.Data.GMPMissingPersonEntities(); Models.Data.misper_ person = entities.misper_.Where(x => x.Unique_ID == sighting.UserID).FirstOrDefault(); if (person == null) { throw new HttpException("Person not found"); } else { var socialMediaType = entities.LocationTypes.Where(x => x.LocationCode == "APSIG").FirstOrDefault(); var location = new Models.Data.Location(); location.Unique_ID = person.Unique_ID; location.ContactNumber = sighting.ContactNumber; location.Latitude = sighting.Latitude; location.LocationTypeID = socialMediaType.ID; location.Verified = "N"; location.SightingDate = DateTime.Now; entities.Locations.Add(location); entities.Locations.AddOrUpdate(); entities.SaveChanges(); person.Locations.Add(location); var phoneData = new Models.Data.PhoneData(); location.PhoneDatas.Add(phoneData); phoneData.LocationID = location.ID; phoneData.DeviceID = sighting.DeviceID; entities.PhoneDatas.AddOrUpdate(); entities.misper_.AddOrUpdate(); entities.SaveChanges(); } }
public async Task AddAndGetAsyncTest() { long sightingId = (await _factory.Sightings.AddAsync(Altitude, AsyncSightingDate, _locationId, _flightId, _aircraftId)).Id; Sighting sighting = await _factory.Sightings.GetAsync(a => a.Id == sightingId); Assert.IsNotNull(sighting); Assert.AreEqual(sightingId, sighting.Id); Assert.AreEqual(Altitude, sighting.Altitude); Assert.AreEqual(AsyncSightingDate, sighting.Date); Assert.IsNotNull(sighting.Location); Assert.AreEqual(_locationId, sighting.Location.Id); Assert.AreEqual(LocationName, sighting.Location.Name); Assert.IsNotNull(sighting.Flight); Assert.AreEqual(_flightId, sighting.Flight.Id); Assert.AreEqual(FlightNumber, sighting.Flight.Number); Assert.AreEqual(Embarkation, sighting.Flight.Embarkation); Assert.AreEqual(Destination, sighting.Flight.Destination); Assert.IsNotNull(sighting.Flight.Airline); Assert.AreEqual(AirlineName, sighting.Flight.Airline.Name); Assert.IsNotNull(sighting.Aircraft); Assert.AreEqual(_aircraftId, sighting.Aircraft.Id); Assert.AreEqual(Registration, sighting.Aircraft.Registration); Assert.AreEqual(SerialNumber, sighting.Aircraft.SerialNumber); Assert.AreEqual(YearOfManufacture, sighting.Aircraft.Manufactured); Assert.IsNotNull(sighting.Aircraft.Model); Assert.AreEqual(ModelName, sighting.Aircraft.Model.Name); Assert.IsNotNull(sighting.Aircraft.Model.Manufacturer); Assert.AreEqual(ManufacturerName, sighting.Aircraft.Model.Manufacturer.Name); }
public void ChangeSighting(Sighting s, int Xpoint, int Ypoint, int sightingKindID, int animalID) { s.Xpoint = Xpoint; s.Ypoint = Ypoint; s.sightingKindID = sightingKindID; s.animalID = animalID; }
public Sighting Update(Sighting sightingObject) { using (var db = new SqlConnection(_connectionString)) { var updatedSighting = db.QueryFirstOrDefault <Sighting>( @"update Sightings set UserId = @userId, Title = @title, Location = @location, Description = @description, ImageUrl = @imageUrl, VideoUrl = @videoUrl, DateCreated = @dateCreated, ThreatLevel = @threatlevel, IsActive = @isActive, IsAnon = @isAnon, Latitude = @latitude, Longitude = @longitude output inserted.* where Id = @id", sightingObject); if (updatedSighting != null) { return(updatedSighting); } } throw new Exception("Sighting did not update"); }
private void Execute(IDomainEvent domainEvent, Sighting sighting, IEnumerable <Project> projects) { dynamic activity = MakeActivity( domainEvent, "sightingadded", sighting.CreatedOn, string.Format("{0} added a sighting", domainEvent.User.GetName()), sighting.Groups.Select(x => x.Group), sighting.Id); if (sighting is Observation) { activity.ObservationAdded = new { Observation = _sightingViewFactory.Make(sighting, domainEvent.User, projects, null) }; } else { activity.RecordAdded = new { Record = _sightingViewFactory.Make(sighting, domainEvent.User, projects, null) }; } _documentSession.Store(activity); _documentSession.SaveChanges(); _backChannelService.SendActivityToGroupChannel(activity); }
/// <summary> /// Delete the species with the specified name /// </summary> /// <param name="name"></param> public async Task DeleteAsync(string name) { // Get the species and make sure it exists name = _textInfo.ToTitleCase(name.CleanString()); Species species = await GetAsync(l => l.Name == name); if (species == null) { string message = $"Species '{name}' does not exist"; throw new SpeciesDoesNotExistException(message); } // Check the species isn't used in any sightings Sighting sighting = await _factory.Context .Sightings .AsAsyncEnumerable() .FirstOrDefaultAsync(s => s.SpeciesId == species.Id); if (sighting != null) { string message = $"Cannot delete speceis '{name}' while it is referenced in sightings"; throw new SpeciesIsInUseException(message); } // Delete the species _factory.Context.Species.Remove(species); await _factory.Context.SaveChangesAsync(); }
/// <summary> /// Delete the location with the specified name /// </summary> /// <param name="name"></param> public async Task DeleteAsync(string name) { // Get the location and make sure it exists name = _textInfo.ToTitleCase(name.CleanString()); Location location = await GetAsync(l => l.Name == name); if (location == null) { string message = $"Location '{name}' does not exist"; throw new LocationDoesNotExistException(message); } // Check the location isn't used in any sightings Sighting sighting = await _factory.Context .Sightings .AsAsyncEnumerable() .FirstOrDefaultAsync(s => s.LocationId == location.Id); if (sighting != null) { string message = $"Cannot delete location '{name}' while it is referenced in sightings"; throw new LocationIsInUseException(message); } // Delete the location _factory.Context.Locations.Remove(location); await _factory.Context.SaveChangesAsync(); }
/// <summary> /// Add a new sighting /// </summary> /// <param name="altitude"></param> /// <param name="date"></param> /// <param name="locationId"></param> /// <param name="flightId"></param> /// <param name="aircraftId"></param> /// <returns></returns> public async Task <Sighting> AddAsync(long altitude, DateTime date, long locationId, long flightId, long aircraftId) { Sighting sighting = new Sighting { Altitude = altitude, Date = date, LocationId = locationId, FlightId = flightId, AircraftId = aircraftId }; await _factory.Context.Sightings.AddAsync(sighting); await _factory.Context.SaveChangesAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Location).LoadAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Flight).LoadAsync(); await _factory.Context.Entry(sighting.Flight).Reference(f => f.Airline).LoadAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Aircraft).LoadAsync(); await _factory.Context.Entry(sighting.Aircraft).Reference(a => a.Model).LoadAsync(); await _factory.Context.Entry(sighting.Aircraft.Model).Reference(m => m.Manufacturer).LoadAsync(); return(sighting); }
public async Task <ActionResult <Sighting> > UpdateSightingAsync([FromBody] Sighting template) { // TODO This logic should be in the business logic Sighting sighting = await _factory.Sightings.GetAsync(s => s.Id == template.Id); if (sighting == null) { return(NotFound()); } sighting.Date = template.Date; sighting.AircraftId = template.AircraftId; sighting.Altitude = template.Altitude; sighting.FlightId = template.FlightId; sighting.LocationId = template.LocationId; await _factory.Context.SaveChangesAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Aircraft).LoadAsync(); await _factory.Context.Entry(sighting.Aircraft).Reference(m => m.Model).LoadAsync(); await _factory.Context.Entry(sighting.Aircraft.Model).Reference(m => m.Manufacturer).LoadAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Flight).LoadAsync(); await _factory.Context.Entry(sighting.Flight).Reference(f => f.Airline).LoadAsync(); await _factory.Context.Entry(sighting).Reference(s => s.Location).LoadAsync(); return(sighting); }
public object Make(Sighting sighting, SightingNote sightingNote, User user, User authenticatedUser) { dynamic viewModel = new ExpandoObject(); viewModel.Id = sightingNote.Id; viewModel.SightingId = sighting.Id; viewModel.CreatedOn = sightingNote.CreatedOn; viewModel.NoteComments = sightingNote.Comments; viewModel.Descriptions = sightingNote.Descriptions; viewModel.Tags = sightingNote.Tags; viewModel.User = _userViewFactory.Make(user, authenticatedUser); viewModel.TagCount = sightingNote.Tags.Count(); viewModel.DescriptionCount = sightingNote.Descriptions.Count(); viewModel.AllTags = string.Join(", ", sightingNote.Tags); viewModel.CreatedOnDescription = sightingNote.CreatedOn.ToString("d MMMM yyyy"); viewModel.TotalVoteScore = sightingNote.Votes.Sum(x => x.Score); // Current user-specific properties if (authenticatedUser != null) { var userId = authenticatedUser.Id; viewModel.UserVoteScore = sightingNote.Votes.Any(x => x.User.Id == userId) ? sightingNote.Votes.Single(x => x.User.Id == userId).Score : 0; viewModel.IsOwner = sightingNote.User.Id == authenticatedUser.Id; } return(viewModel); }
public void EditSighting(Sighting sighting) { sighting.Ispublished = true; using (var db = new SuperheroDBContext()) { Sighting toEdit = db.Sightings.Include("SightingHeroes").SingleOrDefault(s => s.SightingID == sighting.SightingID); if (toEdit != null) { toEdit.SightingDescription = sighting.SightingDescription; toEdit.Date = sighting.Date; toEdit.SightingLocation = db.Locations.Single(l => l.LocationID == sighting.SightingLocation.LocationID); var heroesToDelete = new List <Hero>(); foreach (var hero in toEdit.SightingHeroes) { heroesToDelete.Add(hero); } foreach (var hero in heroesToDelete) { toEdit.SightingHeroes.Remove(hero); } foreach (Hero hero in sighting.SightingHeroes) { toEdit.SightingHeroes.Add(db.Heroes.Single(h => h.HeroID == hero.HeroID)); } db.SaveChanges(); } } }
public object Make(Sighting sighting, SightingNote sightingNote, User user, User authenticatedUser) { dynamic viewModel = new ExpandoObject(); viewModel.Id = sightingNote.Id; viewModel.SightingId = sighting.Id; viewModel.CreatedOn = sightingNote.CreatedOn; viewModel.NoteComments = sightingNote.Comments; viewModel.Descriptions = sightingNote.Descriptions; viewModel.Tags = sightingNote.Tags; viewModel.User = _userViewFactory.Make(user, authenticatedUser); viewModel.TagCount = sightingNote.Tags.Count(); viewModel.DescriptionCount = sightingNote.Descriptions.Count(); viewModel.AllTags = string.Join(", ", sightingNote.Tags); viewModel.CreatedOnDescription = sightingNote.CreatedOn.ToString("d MMMM yyyy"); viewModel.TotalVoteScore = sightingNote.Votes.Sum(x => x.Score); // Current user-specific properties if (authenticatedUser != null) { var userId = authenticatedUser.Id; viewModel.UserVoteScore = sightingNote.Votes.Any(x => x.User.Id == userId) ? sightingNote.Votes.Single(x => x.User.Id == userId).Score : 0; viewModel.IsOwner = sightingNote.User.Id == authenticatedUser.Id; } return viewModel; }
public void AddAndGetTest() { Sighting sighting = _factory.Sightings.Get(a => a.Id == _sightingId); Assert.IsNotNull(sighting); Assert.AreEqual(Altitude, sighting.Altitude); Assert.AreEqual(SightingDate, sighting.Date); Assert.IsNotNull(sighting.Location); Assert.AreEqual(LocationName, sighting.Location.Name); Assert.IsNotNull(sighting.Flight); Assert.AreEqual(FlightNumber, sighting.Flight.Number); Assert.AreEqual(Embarkation, sighting.Flight.Embarkation); Assert.AreEqual(Destination, sighting.Flight.Destination); Assert.IsNotNull(sighting.Flight.Airline); Assert.AreEqual(AirlineName, sighting.Flight.Airline.Name); Assert.IsNotNull(sighting.Aircraft); Assert.AreEqual(Registration, sighting.Aircraft.Registration); Assert.AreEqual(SerialNumber, sighting.Aircraft.SerialNumber); Assert.AreEqual(DateTime.Now.Year - Age, sighting.Aircraft.Manufactured); Assert.IsNotNull(sighting.Aircraft.Model); Assert.AreEqual(ModelName, sighting.Aircraft.Model.Name); Assert.IsNotNull(sighting.Aircraft.Model.Manufacturer); Assert.AreEqual(ManufacturerName, sighting.Aircraft.Model.Manufacturer.Name); }
private void EditSighting(CommandContext context) { // The arguments specify the sighting ID, that must correspond to // an existing location Sighting sighting = null; if (int.TryParse(context.Arguments[1], out int id)) { sighting = context.Factory.Sightings .Get(s => s.Id == id); } if (sighting == null) { string message = $"Sighting '{context.Arguments[1]}' does not exist"; throw new SightingDoesNotExistException(message); } // Prompt for sighting details, using the current values as defaults Sighting updated = PromptForSighting(context, sighting); if (updated != null) { // Save the changes to the database context.Factory.Context.Entry(sighting).State = EntityState.Detached; context.Factory.Context.Entry(updated).State = EntityState.Modified; context.Factory.Context.SaveChanges(); // Report the update context.Output.WriteLine($"Updated sighting '{sighting.Id}"); context.Output.Flush(); } }
public void EFListSightingsById(int sightingID, bool expected) { EFSightingRepo repo = new EFSightingRepo(); Sighting sighting = repo.GetSightingsById(sightingID); bool result = !(sighting.SightingDescription == null); Assert.AreEqual(result, expected); }
// Post api/<controller> public void Post([FromBody] Sighting value) { if (value != null) { var sightingsController = new SightingsController(); sightingsController.APIAdd(value); } }
public async Task DeleteAsyncTest() { Sighting sighting = await _factory.Sightings.ListAsync(null, 1, int.MaxValue).FirstAsync(); await _factory.Sightings.DeleteAsync(sighting.Id); Assert.AreEqual(0, _factory.Context.Sightings.Count()); }
/// <summary> /// Retrieve a sighting given its ID /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <Sighting> GetSightingAsync(int id) { string route = @$ "{_settings.Value.ApiRoutes.First(r => r.Name == RouteKey).Route}/{id}/"; string json = await SendDirectAsync(route, null, HttpMethod.Get); Sighting sighting = JsonConvert.DeserializeObject <Sighting>(json); return(sighting); }
public ActionResult Vote() { var req = Request.InputStream; var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); var json = new StreamReader(req).ReadToEnd(); var data = JsonConvert.DeserializeObject <VoteData>(json); Sighting sighting = db.Sightings.Find(data.Id); sighting.Rating = data.Increase ? sighting.Rating + 1 : sighting.Rating - 1; db.Entry(sighting).State = EntityState.Modified; var preVote = db.Votes.Where(xx => xx.AspNetUserId == userId && xx.SightingId == data.Id).FirstOrDefault(); if (preVote != null) { db.Votes.Remove(preVote); } Vote vote = new Vote(); vote.SightingId = data.Id; vote.AspNetUserId = userId; if (data.Increase) { vote.Action = VoteAction.Up; } else { vote.Action = VoteAction.Down; } db.Votes.Add(vote); db.SaveChanges(); var sightingMapped = new SightingDTO(); sightingMapped.SightingId = sighting.SightingId; sightingMapped.AspNetUserId = sighting.AspNetUserId; sightingMapped.Latitude = sighting.Latitude; sightingMapped.Longitude = sighting.Longitude; sightingMapped.PokeMon = sighting.PokeMon != null?sighting.PokeMon.GetDescription() : null; sightingMapped.Rarity = sighting.Rarity.GetDescription(); sightingMapped.Rating = sighting.Rating; sightingMapped.SightingId = sighting.SightingId; sightingMapped.Type = sighting.Type.GetDescription(); sightingMapped.TimeOfDay = sighting.TimeOfDay.ToString(); return(Json(sightingMapped, JsonRequestBehavior.AllowGet)); }
public IActionResult CreateSighting(string description, string type, DateTime time, string address, string city, string state, int id, int idUser) { Sighting newSighting = new Sighting(description, type, DateTime.Now, address, city, state, idUser); newSighting.Save(idUser); newSighting.ConvertToLatLongAsync(Sighting.GetLastAddress()); newSighting.Alert(); return(RedirectToAction("UserAccount", "Users", new { id = idUser })); //return RedirectToAction("Copies", new { id = bookId }); }
public IActionResult Index() { Dictionary <string, object> model = new Dictionary <string, object>(); string allSightings = Sighting.GetSightings(); List <Sighting> sightingsList = Sighting.GetSightingsList(); model.Add("sightings", allSightings); model.Add("sightingsList", sightingsList); return(View(model)); }
public ActionResult CreateSighting() { var req = Request.InputStream; var json = new StreamReader(req).ReadToEnd(); var result = JsonConvert.DeserializeObject <Sighting>(json); var bounds = JsonConvert.DeserializeObject <Bounds>(json); if (!IsSightingDuplicate(result, bounds)) { var userId = System.Web.HttpContext.Current.User.Identity.GetUserId(); var sighting = new Sighting(); sighting.Longitude = result.Longitude; sighting.Latitude = result.Latitude; sighting.AspNetUserId = userId; sighting.Type = result.Type; sighting.Rarity = result.Rarity; sighting.PokeMon = result.PokeMon; sighting.TimeOfDay = result.TimeOfDay; sighting.Notes = result.Notes; db.Sightings.Add(sighting); db.SaveChanges(); Vote vote = new Vote(); vote.SightingId = sighting.SightingId; vote.AspNetUserId = userId; vote.Action = VoteAction.Up; db.Votes.Add(vote); db.SaveChanges(); var sightingMapped = new SightingDTO(); sightingMapped.SightingId = sighting.SightingId; sightingMapped.AspNetUserId = sighting.AspNetUserId; sightingMapped.Latitude = sighting.Latitude; sightingMapped.Longitude = sighting.Longitude; sightingMapped.PokeMon = sighting.PokeMon != null?sighting.PokeMon.GetDescription() : null; sightingMapped.Rarity = sighting.Rarity.GetDescription(); sightingMapped.Rating = sighting.Rating; sightingMapped.SightingId = sighting.SightingId; sightingMapped.Type = sighting.Type.GetDescription(); sightingMapped.TimeOfDay = sighting.TimeOfDay.ToString(); sightingMapped.Notes = sighting.Notes; return(Json(sightingMapped, JsonRequestBehavior.AllowGet)); } else { return(new HttpStatusCodeResult(409, "This pokemon has already been added to this area")); } }
public ActionResult DownVote(int id) { Sighting sighting = db.Sightings.Find(id); sighting.Rating = sighting.Rating - 1; db.Entry(sighting).State = EntityState.Modified; db.SaveChanges(); return(Json(sighting, JsonRequestBehavior.AllowGet)); }
public async Task <ActionResult <Sighting> > CreateSightingAsync([FromBody] Sighting template) { Sighting location = await _factory.Sightings .AddAsync(template.Altitude, template.Date, template.LocationId, template.FlightId, template.AircraftId); return(location); }
public ActionResult PublishSighting(int ID) { var repo = SightingRepoFactory.Create(); Sighting sighting = repo.GetSightingsById(ID); sighting.Ispublished = true; repo.EditSighting(sighting); return(RedirectToAction("PendingSightings")); }
public IActionResult UserAccount(int id) { Dictionary <string, object> model = new Dictionary <string, object>(); User newUser = IceTracker.Models.User.FindAUserById(id); string allSightings = Sighting.GetSightings(); List <Sighting> sightingsList = Sighting.GetSightingsList(); model.Add("user", newUser); model.Add("sightings", allSightings); model.Add("sightingsList", sightingsList); return(View(model)); }
public object MakeUpdateSightingNote(Sighting sighting, User user, int sightingNoteId) { var sightingNote = sighting.Notes.Single(x => x.SequentialId == sightingNoteId); dynamic viewModel = new ExpandoObject(); viewModel.Id = sightingNoteId; viewModel.SightingId = sighting.Id; viewModel.Descriptions = sightingNote.Descriptions.Select(x => new { Key = x.Id, Value = x.Text, x.Description, x.Group, x.Label }); viewModel.Tags = string.Join(", ", sightingNote.Tags); viewModel.NoteComments = sightingNote.Comments; return viewModel; }