예제 #1
0
        public HttpResponseMessage CreateActivity(Activity activityToAdd)
        {
            activityService.CreateActivity(activityToAdd);
            var responnse = Request.CreateResponse(HttpStatusCode.Created, activityToAdd);

            return responnse;
        }
예제 #2
0
        public void UpdateActivity(Activity activityToUpdate)
        {
            activityToUpdate.Location = uow.LocationRepository.GetByID(activityToUpdate.LocationId);

            uow.ActivityRepository.Update(activityToUpdate);
            uow.Commit();
        }
예제 #3
0
        public void CreateActivity(Activity activityToAdd)
        {
            activityToAdd.Time = activityToAdd.Time.ToUniversalTime();
            activityToAdd.Location = uow.LocationRepository.GetByID(activityToAdd.LocationId);

            uow.ActivityRepository.Insert(activityToAdd);
            uow.Commit();
        }
예제 #4
0
        public ActivityDTO(Activity activity)
        {
            if (activity != null)
            {
                ActivityId = activity.ActivityId;
                Name = activity.Name;
                DayOfWeek = activity.DayOfWeek;

                Time = String.Format("{0:T}", activity.Time);
                LocationId = activity.LocationId;
                Active = activity.Active;

                PreferredNumberOfPlayers1 = activity.PreferredNumberOfPlayers1;
                RequiredNumberOfPlayers1 = activity.RequiredNumberOfPlayers1;
            }            
        }
예제 #5
0
        public HttpResponseMessage UpdateActivity(Activity activityToUpdate)
        {
            //activityToUpdate.Time = activityToUpdate.Time.ToUniversalTime();

            activityService.UpdateActivity(activityToUpdate);
            var responnse = Request.CreateResponse(HttpStatusCode.OK);

            return responnse;
        }
예제 #6
0
        /// <summary>
        /// Checks in the second parameter if there exists an event that was created out of the activity
        /// passed in as a first parameter
        /// </summary>
        /// <param name="activity"> Parameter whose existance we want to confirm </param>
        /// <param name="currentlyExistingEvents"> List of events where we will check for existing events </param>
        /// <returns></returns>
        private bool IsAlreadyEventForToday(Activity activity, IEnumerable<Event> currentlyExistingEvents)
        {
            var result = false;
            var listOfEvents = currentlyExistingEvents as List<Event>;

            if (listOfEvents.Count == 0)
            {
                return result = false;
            }

            foreach (var ev in currentlyExistingEvents)
            {
                // Weird ass error where eager loading fails...
                try
                {
                    // If there is an event of such name that was created today
                    if (ev.Activity.Name == activity.Name &&
                        ev.DateCreated.Date == DateTime.Today.Date)
                    {
                        result = true;
                        return result;
                    }
                }
                catch (Exception e)
                {
                    ev.Activity = activityService.GetActivityById(ev.ActivityId);
                    if (ev.Activity.Name == activity.Name)
                    {
                        result = true;
                        return result;
                    }
                }
            }

            return result;
        }