Example #1
0
        public Athlete RegisterAthlete(Athlete athlete)
        {
            Athlete savingAthlete = new Athlete()
            {
                UserName         = athlete.UserName,
                Surname          = athlete.Surname,
                Country          = athlete.Country,
                FirstName        = athlete.FirstName,
                DateOfBirth      = athlete.DateOfBirth,
                EmailAddress     = athlete.EmailAddress,
                Gender           = athlete.Gender,
                Password         = athlete.Password,
                SecurityQuestion = athlete.SecurityQuestion,
                SecurityAnswer   = athlete.SecurityAnswer,
                Deleted          = false,
                DateJoined       = athlete.DateJoined
            };

            DbContext.Athlete.Add(savingAthlete);

            DbContext.SaveChanges();
            Athlete newAthlete = GetAthletesQuery()
                                 .Where(a => a.FirstName == athlete.FirstName &&
                                        a.EmailAddress == athlete.EmailAddress &&
                                        a.Password == athlete.Password)
                                 .Single();

            return(newAthlete);
        }
Example #2
0
        //add addEvent
        public Event AddEvent(Event evnt)
        {
            Event newEvent = new Event();

            newEvent.Title       = evnt.Title;
            newEvent.Description = evnt.Description;
            newEvent.Date        = evnt.Date;
            newEvent.Time        = evnt.Time;
            newEvent.Location    = evnt.Location;
            newEvent.UserID      = evnt.UserID;
            newEvent.ClubID      = evnt.ClubID;
            newEvent.DateCreated = evnt.DateCreated;

            foreach (EventRoute evntRoute in evnt.EventRoute)
            {
                EventRoute route = new EventRoute();
                route.Title       = evntRoute.Title;
                route.Description = evnt.Description;
                route.RouteID     = evntRoute.RouteID;
                route.DateAdded   = evntRoute.DateAdded;
                route.Distance    = evntRoute.Distance;
                newEvent.EventRoute.Add(route);
            }
            DbContext.Event.Add(newEvent);
            DbContext.SaveChanges();
            return(newEvent);
        }
Example #3
0
 public EventRegistration Register(EventRegistration reg)
 {
     reg.EventStatus = RegistrationType.Registered;
     reg.Deleted     = false;
     DbContext.EventRegistration.Add(reg);
     DbContext.SaveChanges();
     return(reg);
 }
Example #4
0
        public override void Delete(int entity)
        {
            Run deletedRun = DbContext.Run.FirstOrDefault(x => x.RunId == entity);

            if (deletedRun != null)
            {
                deletedRun.Deleted = true;
                DbContext.Entry(deletedRun).State = EntityState.Modified;
                DbContext.SaveChanges();
            }
        }
Example #5
0
        public override void Delete(int entity)
        {
            Club cl = GetClubByID(entity);

            cl.Deleted = true;
            DbContext.SaveChanges();
        }
Example #6
0
        public Route AddRoute(Route route)
        {
            Route savingRoute = new Route();

            savingRoute.UserID       = route.UserID;
            savingRoute.Title        = route.Title;
            savingRoute.DateRecorded = route.DateRecorded;
            savingRoute.Distance     = route.Distance;
            savingRoute.Location     = route.Location;
            foreach (Checkpoint chps in route.Checkpoint)
            {
                Checkpoint checks = new Checkpoint(chps.Latitude, chps.Longitude);
                DbContext.Checkpoint.Add(checks);
                savingRoute.Checkpoint.Add(checks);
            }

            //create map image?
            DbContext.Route.Add(savingRoute);
            DbContext.SaveChanges();
            return(savingRoute);
        }
Example #7
0
 public void Commit()
 {
     DbContext.SaveChanges();
 }