Example #1
0
        public Route Create(RoutePostModel route, User addedBy)
        {
            Route toAdd = RoutePostModel.ToRoute(route);

            toAdd.Owner = addedBy;
            context.Routes.Add(toAdd);
            context.SaveChanges();
            return(toAdd);
        }
Example #2
0
        public Route Upsert(int id, Route route)
        {
            var existing = context.Routes.AsNoTracking().FirstOrDefault(r => r.Id == id);

            if (existing == null)
            {
                context.Routes.Add(route);
                context.SaveChanges();
                return(route);
            }
            route.Id = id;
            context.Routes.Update(route);
            context.SaveChanges();
            return(route);
        }