public HttpResponseMessage CreateActivity(Activity activityToAdd) { activityService.CreateActivity(activityToAdd); var responnse = Request.CreateResponse(HttpStatusCode.Created, activityToAdd); return responnse; }
public void UpdateActivity(Activity activityToUpdate) { activityToUpdate.Location = uow.LocationRepository.GetByID(activityToUpdate.LocationId); uow.ActivityRepository.Update(activityToUpdate); uow.Commit(); }
public void CreateActivity(Activity activityToAdd) { activityToAdd.Time = activityToAdd.Time.ToUniversalTime(); activityToAdd.Location = uow.LocationRepository.GetByID(activityToAdd.LocationId); uow.ActivityRepository.Insert(activityToAdd); uow.Commit(); }
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; } }
public HttpResponseMessage UpdateActivity(Activity activityToUpdate) { //activityToUpdate.Time = activityToUpdate.Time.ToUniversalTime(); activityService.UpdateActivity(activityToUpdate); var responnse = Request.CreateResponse(HttpStatusCode.OK); return responnse; }
/// <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; }