public IActionResult Delete(int id) { var Activity = repository.Activities.SingleOrDefault(x => x.ID == id); if (Activity == null) { return(NotFound()); } repository.DeleteActivity(id); return(Get()); }
public IActionResult Delete(Guid id) { var activity = activityRepository.GetActivity(id); activityRepository.DeleteActivity(activity); return(Ok()); }
public ActionResult DeleteConfirmed(int id) { Activity activity = activityRepository.GetActivityByID((int)id); activityRepository.DeleteActivity((int)id); activityRepository.Save(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Delete(int id) { if (await _activityRepository.DeleteActivity(id)) { return(NoContent()); } else { return(NotFound()); } }
public IActionResult Delete(int id) { bool result = _activityRepository.DeleteActivity(id); if (result) { return(NoContent()); } else { return(NotFound()); } }
public IActionResult DeleteActivity([FromRoute] Guid activityId) { if (!_activityRepository.ActivityExists(activityId)) { return(NotFound("未找到对应活动")); } var Activity = _activityRepository.GetActivity(activityId); _activityRepository.DeleteActivity(Activity); _activityRepository.Save(); return(NoContent()); }
public async Task <ActionResult> DeleteActivity(int id) { try { await _activityRepository.DeleteActivity(id); } catch (Exception e) { return(Problem(e.Message)); } return(Ok()); }
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 }
public bool DeleteActivity(int id) { return(activityRepository.DeleteActivity(id)); }
/// <summary> /// 删除拥有者动态 /// </summary> /// <param name="activityId">动态Id</param> public void DeleteActivity(long activityId) { activityRepository.DeleteActivity(activityId); }
public void DeleteActivity(int id) { activityRepository.DeleteActivity(id); activityRepository.Save(); }
public ActionResult Delete(int id) { activityContext.DeleteActivity(id); return(Ok()); }
public void RemoveActivity(Activity activity) { _activityRepository.DeleteActivity(activity); }