コード例 #1
0
        public IActionResult Delete(int id)
        {
            var Activity = repository.Activities.SingleOrDefault(x => x.ID == id);

            if (Activity == null)
            {
                return(NotFound());
            }
            repository.DeleteActivity(id);
            return(Get());
        }
コード例 #2
0
        public IActionResult Delete(Guid id)
        {
            var activity = activityRepository.GetActivity(id);

            activityRepository.DeleteActivity(activity);

            return(Ok());
        }
コード例 #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            Activity activity = activityRepository.GetActivityByID((int)id);

            activityRepository.DeleteActivity((int)id);
            activityRepository.Save();
            return(RedirectToAction("Index"));
        }
コード例 #4
0
 public async Task <ActionResult> Delete(int id)
 {
     if (await _activityRepository.DeleteActivity(id))
     {
         return(NoContent());
     }
     else
     {
         return(NotFound());
     }
 }
コード例 #5
0
        public IActionResult Delete(int id)
        {
            bool result = _activityRepository.DeleteActivity(id);

            if (result)
            {
                return(NoContent());
            }
            else
            {
                return(NotFound());
            }
        }
コード例 #6
0
        public IActionResult DeleteActivity([FromRoute] Guid activityId)
        {
            if (!_activityRepository.ActivityExists(activityId))
            {
                return(NotFound("未找到对应活动"));
            }
            var Activity = _activityRepository.GetActivity(activityId);

            _activityRepository.DeleteActivity(Activity);
            _activityRepository.Save();

            return(NoContent());
        }
コード例 #7
0
        public async Task <ActionResult> DeleteActivity(int id)
        {
            try
            {
                await _activityRepository.DeleteActivity(id);
            }
            catch (Exception e)
            {
                return(Problem(e.Message));
            }

            return(Ok());
        }
コード例 #8
0
        public void Init()
        {
            #region Dummy Activity List
            activities = new List <Activity>
            {
                new Activity {
                    ActivityID = 1, Name = "Gimnasio", Description = "Gimnasio, pesas, bicicletas, máquinas para correr"
                },
                new Activity {
                    ActivityID = 2, Name = "Pilates", Description = "Sistema de entrenamiento físico y mental"
                },
                new Activity {
                    ActivityID = 3, Name = "Boxeo", Description = "Deporte de combate"
                },
                new Activity {
                    ActivityID  = 4, Name = "Body Pump",
                    Description = "Actividad dirigida que combina ejercicios propios de la sala de musculación (con mancuernas, barras y discos) con la                                      mejor música que permite lograr una completa actividad aeróbica"
                },
                new Activity {
                    Name = "Fit-ball", Description = "Es un sistema de entrenamiento físico diseñado sobre los principios de la fisioterapia. Consiste en realizar ejercicios con una pelota inflable o fit-ball."
                }
            };


            #endregion

            #region Dummy New Activity
            newActivity = new Activity {
                Name = "X55", Description = "Es un moderno y revolucionario programa de resistencia localizada. Son 55 minutos de extrema energía e intensidad,                                                           guiados por una música específica. "
            };
            #endregion

            #region Dummy PaymentType List
            var paymentType = new List <PaymentType>
            {
                new PaymentType {
                    Description = "Gimnasio mensual", Status = Catalog.Status.Active, ActivityID = 1, DurationInMonths = 1
                },
                new PaymentType {
                    Description = "Gimnasio anual", Status = Catalog.Status.Active, ActivityID = 1, DurationInMonths = 12
                },
                new PaymentType {
                    Description = "Pilates mensual", Status = Catalog.Status.Active, ActivityID = 2, DurationInMonths = 1
                },
                new PaymentType {
                    Description = "Boxeo mensual", Status = Catalog.Status.Active, ActivityID = 3, DurationInMonths = 1
                },
            };
            #endregion

            #region Repositories
            activityRepository    = Mock.Create <IActivityRepository>();
            paymentTypeRepository = Mock.Create <IPaymentTypeRepository>();
            #endregion

            #region JustMock GetActivities Arrange
            Mock.Arrange(() => activityRepository.GetActivities()).Returns(activities);
            Mock.Arrange(() => activityRepository.GetActivityByID(ACTIVITY_ID_TO_USE))
            .Returns(activities.Where(a => a.ActivityID == ACTIVITY_ID_TO_USE).FirstOrDefault());
            Mock.Arrange(() => activityRepository.InsertActivity(newActivity))
            .DoInstead(() => activities.Add(newActivity))
            .MustBeCalled();
            Mock.Arrange(() => activityRepository.DeleteActivity(ACTIVITY_ID_TO_USE))
            .DoInstead(() => activities.Remove(activities.Where(a => a.ActivityID == ACTIVITY_ID_TO_USE).FirstOrDefault()));
            Mock.Arrange(() => activityRepository.Save()).DoNothing();
            #endregion

            #region Controller creation
            controller = new ActivitiesController(activityRepository, paymentTypeRepository);
            #endregion
        }
コード例 #9
0
 public bool DeleteActivity(int id)
 {
     return(activityRepository.DeleteActivity(id));
 }
コード例 #10
0
ファイル: ActivityService.cs プロジェクト: yaotyl/spb4mono
 /// <summary>
 /// 删除拥有者动态
 /// </summary>
 /// <param name="activityId">动态Id</param>
 public void DeleteActivity(long activityId)
 {
     activityRepository.DeleteActivity(activityId);
 }
コード例 #11
0
 public void DeleteActivity(int id)
 {
     activityRepository.DeleteActivity(id);
     activityRepository.Save();
 }
コード例 #12
0
        public ActionResult Delete(int id)
        {
            activityContext.DeleteActivity(id);

            return(Ok());
        }
コード例 #13
0
 public void RemoveActivity(Activity activity)
 {
     _activityRepository.DeleteActivity(activity);
 }