public void TearDown()
        {
            if (!string.IsNullOrEmpty(_subscriptionId))
            {
                _sut.DeleteSubscription(_projectId, _subscriptionId);
            }

            _topicService.DeleteTopic(_projectId, _topicId);
        }
        public void TearDown()
        {
            _sut.StopConsuming();

            _subscriptionService.DeleteSubscription(_projectId, _subscriptionId);
            _topicService.DeleteTopic(_projectId, _topicId);
            _subscriptionService.DeleteSubscription(_projectId, _deadLetterSubscriptionId);
            _topicService.DeleteTopic(_projectId, _deadLetterTopicId);
        }
Ejemplo n.º 3
0
 protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
 {
     if (e.CommandName == "DeleteUser")
     {
         SubscriptionService.DeleteSubscription((int.Parse(e.CommandArgument.ToString())));
     }
 }
Ejemplo n.º 4
0
        public async Task <HttpResponseMessage> DeleteSubscription(string Id)
        {
            var  subscriptionService = new SubscriptionService();
            bool isDeleted           = await subscriptionService.DeleteSubscription(Id);

            return(Request.CreateResponse(HttpStatusCode.OK, isDeleted));
        }
Ejemplo n.º 5
0
        public async Task AssertDeleteSubscriptionCallsRepoToDeleteAsync()
        {
            //Given

            //When
            await _subscriptionService.DeleteSubscription(subId, subAccountId);

            //Then
            _mockSubRepo.Verify(m => m.DeleteSubscription(subId, subAccountId));
        }
Ejemplo n.º 6
0
        public ActionResult Unsubscribe(StudentSubscriptionModel model)
        {
            var org      = GetMyOrganisation();
            var semester = SemesterService.GetSemester(model.SemesterName);

            if (semester == null)
            {
                ModelState.AddModelError("SemesterName", "Es existiert kein Semester mit dieser Bezeichnung");
                return(View(model));
            }


            var courses = Db.Activities.OfType <Course>().Where(x =>
                                                                x.ShortName.Equals(model.CourseShortName.Trim()) &&
                                                                x.SemesterGroups.Any(g =>
                                                                                     g.Semester.Id == semester.Id && g.CapacityGroup.CurriculumGroup.Curriculum.Organiser.Id == org.Id)).ToList();

            if (!courses.Any())
            {
                ModelState.AddModelError("CourseShortName", "Es existiert keine Lehrveranstaltung mit dieser Bezeichnung");
                return(View(model));
            }

            if (courses.Count > 1)
            {
                ModelState.AddModelError("CourseShortName", $"Bezeichnung nicht eindeutig. Es existieren {courses.Count} Lehrveranstaltungen mit dieser Bezeichnung");
                return(View(model));
            }

            var host   = GetCurrentUser();
            var course = courses.First();

            var subscription = course.Occurrence.Subscriptions.FirstOrDefault(x => x.UserId.Equals(model.User.Id));

            if (subscription == null)
            {
                ModelState.AddModelError("CourseShortName", "Ist in dieser Lehrveranstaltung nicht eingetragen.");
                return(View(model));
            }

            var subService = new SubscriptionService(Db);

            subService.DeleteSubscription(subscription);

            var mailService = new SubscriptionMailService();

            mailService.SendSubscriptionEMail(course, model.User.Id, host);

            return(RedirectToAction("CoursePlan", new { id = model.User.Id, semId = semester.Id }));
        }
        public IActionResult UpdateSubscription([FromBody] SubscriptionViewModel subscriptionView)
        {
            var userId  = User.GetUserId();
            var student = _studentService.GetStudentByUserId(userId);

            try
            {
                _subscriptionService.DeleteSubscription(subscriptionView.CompanyId, student.Id);
            }
            catch (Exception e)
            {
                return(BadRequest(e));
            }
            return(Ok());
        }
Ejemplo n.º 8
0
 protected void lbDeleteSelected_Click(object sender, EventArgs e)
 {
     if ((_selectionFilter != null) && (_selectionFilter.Values != null))
     {
         if (!_inverseSelection)
         {
             foreach (var id in _selectionFilter.Values)
             {
                 SubscriptionService.DeleteSubscription(SQLDataHelper.GetInt(id));
             }
         }
         else
         {
             var itemsIds = _paging.ItemsIds <int>("ID");
             foreach (int id in itemsIds.Where(iId => !_selectionFilter.Values.Contains(iId.ToString(CultureInfo.InvariantCulture))))
             {
                 SubscriptionService.DeleteSubscription(id);
             }
         }
     }
 }
Ejemplo n.º 9
0
        public IQueryable <SubscriptionDto> Unsubscribe([FromBody] SubscriptionBasketModel model)
        {
            var subService = new SubscriptionService(Db);

            var user = GetUser(model.User.Id);

            foreach (var courseModel in model.Courses)
            {
                var course = Db.Activities.OfType <Course>().SingleOrDefault(x => x.Id == courseModel.Id);

                if (course != null && user != null)
                {
                    var subscription =
                        course.Occurrence.Subscriptions.FirstOrDefault(x => x.UserId.Equals(model.User.Id));

                    if (subscription != null)
                    {
                        subService.DeleteSubscription(subscription);
                    }
                }
            }

            return(new List <SubscriptionDto>().AsQueryable());
        }
 public void TearDown()
 {
     _subscriptionService.DeleteSubscription(_projectId, _subscriptionId);
     _topicService.DeleteTopic(_projectId, _topicId);
 }
Ejemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="id">Id des Kurses</param>
        /// <returns></returns>

        public PartialViewResult Subscribe(Guid id)
        {
            var logger = LogManager.GetLogger("Booking");

            var user    = GetCurrentUser();
            var student = StudentService.GetCurrentStudent(user);
            var course  = Db.Activities.OfType <Course>().SingleOrDefault(x => x.Id == id);
            OccurrenceSubscription succeedingSubscription = null;

            Occurrence             occ          = course.Occurrence;
            OccurrenceSubscription subscription = null;

            using (var transaction = Db.Database.BeginTransaction())
            {
                subscription = occ.Subscriptions.FirstOrDefault(x => x.UserId.Equals(user.Id));

                var bookingService = new BookingService(Db);
                var bookingLists   = bookingService.GetBookingLists(occ.Id);
                var bookingState   = new BookingState
                {
                    Student      = student,
                    Occurrence   = occ,
                    BookingLists = bookingLists
                };
                bookingState.Init();

                var bookingList = bookingState.MyBookingList;

                if (subscription == null)
                {
                    // eintragen
                    // den Status aus den Buchungslisten ermitteln
                    // ermittle Buchungsliste
                    // wenn eine Liste
                    // wenn voll, dann Warteliste
                    // sonst Teilnehmer
                    // sonst
                    // Fehlermeldung an Benutzer mit Angabe des Grunds

                    if (bookingList != null)
                    {
                        subscription = new OccurrenceSubscription
                        {
                            TimeStamp     = DateTime.Now,
                            Occurrence    = occ,
                            UserId        = user.Id,
                            OnWaitingList = bookingState.AvailableSeats <= 0
                        };

                        Db.Subscriptions.Add(subscription);
                    }
                }
                else
                {
                    // austragen
                    var subscriptionService = new SubscriptionService(Db);
                    subscriptionService.DeleteSubscription(subscription);

                    // Nachrücken
                    if (bookingList != null)
                    {
                        var succBooking = bookingList.GetSucceedingBooking();
                        if (succBooking != null)
                        {
                            succBooking.Subscription.OnWaitingList = false;
                            succeedingSubscription = succBooking.Subscription;
                        }
                    }
                }

                Db.SaveChanges();
                transaction.Commit();
            }

            // Mail an Nachrücker versenden
            if (succeedingSubscription != null)
            {
                var mailService = new SubscriptionMailService();
                mailService.SendSucceedingEMail(course, succeedingSubscription);

                var subscriber = GetUser(succeedingSubscription.UserId);
                logger.InfoFormat("{0} ({1}) for [{2}]: set on participient list",
                                  course.Name, course.ShortName, subscriber.UserName);
            }

            // jetzt neu abrufen und anzeigen
            var model = GetBookingStateModel(course.Id);

            return(PartialView("_CourseSummaryBookingBox", model));
        }
Ejemplo n.º 12
0
 public IEnumerable <Subscription> DeleteSubscription(int id) =>
 _subscriptionService.DeleteSubscription(id);