internal bool AddLocationToMap(NewHorizonsDBContext context) { bool result = true; Markers markers = new Markers() { UserID = UserId, Name = Name, Adress = Address, Hours = Hours, Description = Description, LatLng = LatLng, }; try { context.Markers.Add(markers); context.SaveChanges(); } catch { result = false; } return(result); }
internal static bool DeleteMarker(NewHorizonsDBContext context, int locID) { bool locationDeleted; var location = context.Markers.Where(l => l.ID == locID).FirstOrDefault(); if (location != null) { context.Remove(location); context.SaveChanges(); locationDeleted = true; } else { locationDeleted = false; } return(locationDeleted); }
internal static bool UpdateMarker(NewHorizonsDBContext context, EditLocationViewModel model) { bool locationUpdated; var location = context.Markers.Where(l => l.ID == model.ID).FirstOrDefault(); if (location != null) { location.Name = model.Name; location.Hours = model.Hours; location.Adress = model.Adress; location.Description = model.Description; context.SaveChanges(); locationUpdated = true; } else { locationUpdated = false; } return(locationUpdated); }