Esempio n. 1
0
        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);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
        }