Beispiel #1
0
 public void CreateActivitySummery(ActivitySummeryViewModel activitySummeryViewModel, string userId)
 {
     try
     {
         ActivitySummery activitySummery = new ActivitySummery()
         {
             ActivityId          = activitySummeryViewModel.ActivityId,
             WeekDayId           = activitySummeryViewModel.WeekDayId,
             UserId              = userId,
             StartTime           = activitySummeryViewModel.StartTime,
             EndTime             = activitySummeryViewModel.EndTime,
             ActivityDescription = activitySummeryViewModel.Description,
             Activity            = _schemaRepository.GetSpecificActivity(activitySummeryViewModel.ActivityId),
             WeekDay             = _schemaRepository.GetSpecificWeekDay(activitySummeryViewModel.WeekDayId)
         };
         _schemaRepository.CreateActivitySummery(activitySummery);
         _schemaRepository.Save();
         _schemaRepository.Dispose();
         _schemaRepository = new SchemaRepository();
     }
     catch (Exception)
     {
         throw new Exception("Something went wrong when trying to save the activity summery");
     }
 }
Beispiel #2
0
 public void CreateNewGeneratedSchema(List <WeekDayViewModel> weekDays, string userId)
 {
     foreach (WeekDayViewModel weekDay in weekDays)
     {
         weekDay.ActivitiySummeries = weekDay.ActivitiySummeries.Where(x => x.ActivitySummeryId == 0).ToList();
         foreach (ActivitySummeryViewModel activitySummeryViewModel in weekDay.ActivitiySummeries)
         {
             try
             {
                 ActivitySummery activitySummery = new ActivitySummery()
                 {
                     ActivityId          = activitySummeryViewModel.ActivityId,
                     WeekDayId           = activitySummeryViewModel.WeekDayId,
                     UserId              = userId,
                     StartTime           = activitySummeryViewModel.StartTime,
                     EndTime             = activitySummeryViewModel.EndTime,
                     ActivityDescription = activitySummeryViewModel.Description,
                     Activity            = _schemaRepository.GetSpecificActivity(activitySummeryViewModel.ActivityId),
                     WeekDay             = _schemaRepository.GetSpecificWeekDay(activitySummeryViewModel.WeekDayId)
                 };
                 _schemaRepository.CreateActivitySummery(activitySummery);
                 _schemaRepository.Save();
                 _schemaRepository.Dispose();
                 _schemaRepository = new SchemaRepository();
             }
             catch (Exception)
             {
                 throw new Exception("Something went wrong when trying to save the activity summery");
             }
         }
     }
 }
 public void UpdateActivitySummery(ActivitySummery activitySummery)
 {
     if (_schemaApplicationEntities.Entry(activitySummery).State == EntityState.Detached)
     {
         _schemaApplicationEntities.ActivitySummeries.Attach(activitySummery);
     }
     _schemaApplicationEntities.Entry(activitySummery).State = EntityState.Modified;
 }
Beispiel #4
0
        public bool CheckIfActivitySummeryIdBelongsToUser(string userId, int activitySummeryId)
        {
            ActivitySummery activitySummery = _schemaRepository.GetSpecificActivitySummery(activitySummeryId);

            return(activitySummery.UserId == userId);
        }
        public void DeleteActivitySummery(int id)
        {
            ActivitySummery activitySummery = _schemaApplicationEntities.ActivitySummeries.Find(id);

            _schemaApplicationEntities.ActivitySummeries.Remove(activitySummery);
        }
 public void CreateActivitySummery(ActivitySummery activitySummery)
 {
     _schemaApplicationEntities.ActivitySummeries.Add(activitySummery);
 }