Example #1
0
        /// <inheritdoc />
        public override ResponseObject <OrderUpdate> PlaceStoplossOrder(TradingPair pair, OrderSide side, decimal quantity, decimal price, long tradeId)
        {
            // Add the order to the watchlist
            OrderUpdate order = new OrderUpdate(
                orderId: _mockOrderCounter++,
                tradeId: tradeId,
                orderStatus: OrderUpdate.OrderStatus.New,
                orderType: OrderUpdate.OrderTypes.StopLoss,
                createdTimestamp: Timer.CurrentTime.ToUnixTimeMilliseconds(),
                setPrice: 0,
                side: side,
                pair: pair,
                setQuantity: quantity)
            {
                StopPrice = price,
            };

            // Add to order cache to confirm placement.
            _orderCache.Enqueue(order);

            // Add to watchlist to check if filled
            WatchList.Add(order.OrderId, order);

            return(new ResponseObject <OrderUpdate>(ResponseCode.Success, order));
        }
        public async Task HandleWithNullCreateRequestCallRetrunNullWithThrowsException()
        {
            // Arrange
            var watchListEntity = new WatchList {
                MovieId = 299536, Comments = "Avengers: Infinity War is good"
            };
            var watchListModel = new WatchListModel {
                MovieId = 299536, Comments = "Avengers: Infinity War"
            };
            var config = new MapperConfiguration(m => { m.CreateMap <WatchList, WatchListModel>(); });
            var mapper = new Mapper(config);

            repository = new Mock <IRepository>();
            repository.Setup(m => m.Get <WatchList>(It.IsAny <int>()))
            .Returns(watchListEntity);
            createWatchList        = new CreateBooking(repository.Object, mapper);
            createWatchListRequest = new CreateBookingRequest(watchListModel);

            // Act
            CancellationToken cancellationToken;
            var result = await createWatchList.Handle(createWatchListRequest, cancellationToken);

            // Assert
            Assert.Null(result);
        }
        public async Task <IActionResult> Update(string id, [FromBody] WatchListUpdateModel model)
        {
            var watchList = await GetWatchList(id);

            if (watchList == null)
            {
                return(NotFound());
            }

            if (watchList.ReadOnlyProperty ||
                !await IsValidAsync(model.AssetPairIds) ||
                string.IsNullOrEmpty(model.Name))
            {
                return(BadRequest());
            }

            var watchlists = await GetAllWatchlists();

            if (watchlists.Any(item => item.Name == model.Name && item.Id != watchList.Id))
            {
                return(BadRequest());
            }

            var newWatchList = new WatchList
            {
                Id       = id,
                Name     = model.Name,
                Order    = model.Order,
                AssetIds = model.AssetPairIds.ToList()
            };

            await _assetsHelper.UpdateCustomWatchListAsync(_requestContext.ClientId, newWatchList);

            return(Ok(newWatchList.ToApiModel()));
        }
Example #4
0
        public IActionResult WatchList([FromBody] WatchlistPostModel watchlistPostModel)
        {
            var userId    = User.FindFirstValue(ClaimTypes.NameIdentifier);
            var watchList = _watchListRepository.GetWatchListForUserForProduct(userId, watchlistPostModel.ProductId);

            if (watchList == null)
            {
                WatchList newWatchlist = new WatchList()
                {
                    ProductId = watchlistPostModel.ProductId,
                    UserID    = userId,
                };

                _watchListRepository.AddWatchlist(newWatchlist);

                return(Json(new { success = "true" }));
            }

            else if (watchList.UserID.Equals(userId))
            {
                _watchListRepository.RemoveWatchlist(watchList);

                return(Json(new { success = "true" }));
            }


            return(Json(new { success = "false" }));
        }
Example #5
0
        public async Task HandleWithValidCreateRequestCallSaveAsExpectedResult()
        {
            // Arrange
            var watchListEntity = new WatchList {
                MovieId = 299536, Comments = "Avengers: Infinity War is good"
            };

            var config = new MapperConfiguration(m => { m.CreateMap <WatchList, WatchListModel>(); });
            var mapper = new Mapper(config);

            repository = new Mock <IRepository>();
            repository.Setup(m => m.Get <WatchList>(It.IsAny <int>()))
            .Returns(watchListEntity);

            var httpClientStatus = HttpStatusCode.OK;
            var mockHttpClient   = MockHttpClient(httpClientStatus);

            getMovieCruiserById        = new GetMovieCruiserById(mockHttpClient, repository.Object, mapper);
            getMovieCruiserByIdRequest = new GetMovieCruiserByIdRequest(123);

            // Act
            CancellationToken cancellationToken;
            var result = await getMovieCruiserById.Handle(getMovieCruiserByIdRequest, cancellationToken);

            // Assert
            Assert.NotNull(result);
            Assert.Equal("Avengers: Infinity War", result.MovieByIdModel.Title);
            Assert.Equal("Avengers: Infinity War is good", result.MovieByIdModel.Comments);
            Assert.Equal(2, result.RecommendationsMovies.results.Count);
        }
        //Get list of items
        public List <WatchListItemViewModel> GetWatchListItems(HttpContextBase httpContext)
        {
            WatchList watchlist = GetWatchList(httpContext, false);

            if (watchlist != null)
            {
                var result = (from w in watchlist.WatchListItems
                              join s in showContext.Collection()
                              on w.ShowId equals s.Id
                              select new WatchListItemViewModel()
                {
                    Id = w.ShowId,
                    showName = s.Name,
                    Image = s.Image,
                    showDescription = s.Description,
                    showSeason = s.PremieredSeason,
                    showStudio = s.Studio,
                    showEpisodeCount = s.EpisodeCount
                }).ToList();

                return(result);
            }
            else
            {
                return(new List <WatchListItemViewModel>());
            }
        }
        //Internal Methods

        //Pulling watch list
        private WatchList GetWatchList(HttpContextBase httpContext, bool createIfNull)
        {
            HttpCookie cookie    = httpContext.Request.Cookies.Get(WatchListSessionName);
            WatchList  watchList = new WatchList();

            if (cookie != null)
            {
                string watchListId = cookie.Value;
                if (!string.IsNullOrEmpty(watchListId))
                {
                    watchList = watchListContext.Find(watchListId);
                }
                else
                {
                    if (createIfNull)
                    {
                        watchList = CreateNewWatchList(httpContext);
                    }
                }
            }
            else
            {
                if (createIfNull)
                {
                    watchList = CreateNewWatchList(httpContext);
                }
            }
            return(watchList);
        }
Example #8
0
        public IHttpActionResult CreateNewWatchLists(NewWatchListDto newWatchList)
        {
            //First get the member from the context.
            var member = _context.Members
                         .Single(m => m.Id == newWatchList.MemberId);

            //Then get the list of Tv Shows from the database that the member wants to track.
            //This loads multiple Tv Shows.
            //This translates to a sql statement like this:
            //      SELECT *
            //      FROM TvShows
            //      Where Id IN(1, 2, 3, ...)
            var tvShows = _context.TvShows
                          .Where(t => newWatchList.TvShowIds.Contains(t.Id)).ToList();

            //Iterate over the tv shows the member wants to add
            foreach (var tvShow in tvShows)
            {
                //Create a new watchlist record
                var watchList = new WatchList
                {
                    Member      = member,
                    TvShow      = tvShow,
                    ViewingList = "TBD",         //This is where I can initialize the Viewing List
                };

                //Add it to the database
                _context.WatchLists.Add(watchList);
            }

            //Save changes
            _context.SaveChanges();

            return(Ok());
        }
Example #9
0
        public async Task <ResponseModel <IMarginTradingWatchList> > AddWatchList([FromBody] WatchList model)
        {
            var clientId = User.GetClaim(ClaimTypes.NameIdentifier);

            if (clientId == null)
            {
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.NoAccess, "Wrong token"));
            }

            var result = new ResponseModel <IMarginTradingWatchList>();

            if (model.AssetIds == null || model.AssetIds.Count == 0)
            {
                return(ResponseModel <IMarginTradingWatchList> .CreateInvalidFieldError("AssetIds", "AssetIds should not be empty"));
            }

            var addResult = await _watchListService.AddAsync(model.Id, clientId, model.Name, model.AssetIds);

            switch (addResult.Status)
            {
            case WatchListStatus.AssetNotFound:
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.AssetNotFound, $"Asset '{addResult.Message}' is not found or not allowed"));

            case WatchListStatus.ReadOnly:
                return(ResponseModel <IMarginTradingWatchList> .CreateFail(ResponseModel.ErrorCodeType.InconsistentData, "This watch list is readonly"));
            }

            result.Result = addResult.Result;

            return(result);
        }
Example #10
0
        /// <summary>
        /// Constructor
        /// </summary>
        public WatchlistView(WatchList watchlist)
        {
            if (watchlist != null)
            {
                this.watchlist = watchlist;
                InitializeComponent();
                refreshWatchlistDataAsync();
                updateStockPricesInListView();
                mainForm.setHeadline("Watchlist : " + watchlist.Name);
                setDefaultCurrencyInLabel();

                cbxDataProvider.Items.Add(FinanceAPI.FinanceStrategies.Google);
                cbxDataProvider.Items.Add(FinanceAPI.FinanceStrategies.Yahoo);
                cbxDataProvider.SelectedItem = webFinanceStrategy;

                lvwColumnSorter = new ListViewColumnSorter();
                lvWatchlist.ListViewItemSorter = lvwColumnSorter;

                dpEnddate.Value     = endDate;
                dpStartdate.MaxDate = DateTime.Now;
                dpStartdate.Value   = startDate;

                lvWatchlist.Columns.Add("Buchwert");
                lvWatchlist.Columns.Add("Marktkapitalisierung");
                lvWatchlist.Columns.Add("50 Tage");
                lvWatchlist.Columns.Add("250 Tage");

                dpEnddate.ValueChanged   += new EventHandler(datetime_Changed);
                dpStartdate.ValueChanged += new EventHandler(datetime_Changed);
            }
        }
Example #11
0
 //Construtor base
 public Movie()
 {
     title       = "Insert movie title";
     releaseDate = DateTime.MinValue;
     duration    = 0;
     watched     = 0;
 }
Example #12
0
 private void closeRightForm()
 {
     splitContainerMain.Panel2Collapsed = true;
     btnAddWatchlist.Visible            = true;
     btnDeleteWatchlist.Visible         = true;
     selected = null;
 }
        public void WatchListAdd(Guid ID, Guid UserID)
        {
            try
            {
                using (GflixDBContext Context = new GflixDBContext())
                {
                    var WatchListData = (from watch in Context.WatchList
                                         where watch.UserId == UserID && watch.ContentId == ID
                                         select watch).FirstOrDefault();

                    if (WatchListData == null)
                    {
                        WatchList watch = new WatchList()
                        {
                            Id          = Guid.NewGuid(),
                            ContentId   = ID,
                            DateCreated = DateTime.Now,
                            UserId      = UserID
                        };

                        Context.WatchList.Add(watch);
                        Context.SaveChanges();
                    }
                }
            }
            catch (Exception ex)
            {
                throw new CustomException("DATABASE_INTERNAL_EXCEPTION");
            }
        }
Example #14
0
        public async Task <IActionResult> AddMovieToWatchlist([FromRoute] int id)
        {
            Movie movie = _movieRepository.GetSingle(m => m.ID == id);

            if (movie == null)
            {
                return(NotFound());
            }

            var userName = _userManager.GetUserId(User);
            var user     = await _userManager.FindByNameAsync(userName);

            var movieAlreadyOnWatchlist = _context.WatchLists.Where(wl => wl.User.Id == user.Id && wl.MovieID == id).FirstOrDefault();

            if (movieAlreadyOnWatchlist != null)
            {
                return(NotFound());
            }

            var watchList = new WatchList
            {
                MovieID = movie.ID,
                UserID  = user.Id
            };

            _context.WatchLists.Add(watchList);
            _context.SaveChanges();

            return(new OkObjectResult(0));
        }
Example #15
0
        /// <inheritdoc />
        public override void OnNext(long value)
        {
            while (_orderCache.TryDequeue(out var cachedOrder))
            {
                UpdateObservers(cachedOrder);
            }

            foreach (var order in WatchList.Values.ToList())
            {
                var candle = _dataProvider.ParentImplementation.GetCandles(order.Pair, 1)[0];

                if (EvaluateFilledOrder(order, candle, Timer.CurrentTime.ToUnixTimeMilliseconds()))
                {
                    Logger.LogInformation($"Order {order.OrderId} confirmed at {Timer.CurrentTime}");

                    // Write the filled trade to the logger
                    LogOrder(order);

                    UpdateObservers(order);
                }
            }

            // Clean up filled orders
            WatchList = WatchList
                        .Where(keyPair => !keyPair.Value.Finalized)
                        .ToDictionary(p => p.Key, p => p.Value);
        }
        public async Task <IActionResult> Add([FromBody] WatchListViewModel watchListViewModel)
        {
            try
            {
                bool isExistedWatchListByStudentIdAndCourseId = await watchListRepository.IsExistedWatchListByStudentIdAndCourseId(watchListViewModel.StudentId, watchListViewModel.CourseId);

                if (isExistedWatchListByStudentIdAndCourseId == true)
                {
                    return(BadRequest(new
                    {
                        Errors = new { Code = "ExistedWatchList", Description = "WatchList has already existed!" }
                    }));
                }

                WatchList watchListMapped = mapper.Map <WatchList>(watchListViewModel);

                await watchListRepository.Add(watchListMapped);

                return(Ok(new
                {
                    Results = watchListMapped
                }));
            }
            catch (Exception e)
            {
                Console.WriteLine($"ErrorMesages: {e}");

                return(BadRequest(new
                {
                    Errors = new { Code = "InvalidInputParameters", Description = "Invalid Input Parameters!" }
                }));
            }
        }
        public async Task <IHttpActionResult> Post(WatchList watchList)
        {
            try
            {
                if (watchList.Id > 0)
                {
                    if (!watchList.IsSystem)
                    {
                        var currentUser = await GetCurrentUser();

                        watchList.Owner = currentUser.Id;
                    }
                    else
                    {
                        watchList.Owner = "System";
                    }

                    (new WatchListBLL(_unit)).Update(watchList);
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(_log, ex.ToString());
                return(InternalServerError(ex));
            }
            return(Ok(watchList));
        }
        public async Task <ActionResult> RemoveFromWatchList(int pId, string isBundle)
        {
            AspNetUser user = await Utility.Util.getUser(HttpContext.User);

            Product p = await db.Product.FindAsync(pId);

            Bundle b = await db.Bundles.FindAsync(pId);

            WatchList wl = null;

            if (isBundle.Equals("yes"))
            {
                wl = await(from x in db.WatchList
                           where x.customerId == user.Id && x.bundleId == b.bundleId
                           select x).FirstAsync();
            }
            else
            {
                wl = await(from x in db.WatchList
                           where x.customerId == user.Id && x.productID == p.productID
                           select x).FirstAsync();
            }

            if (wl != null)
            {
                db.WatchList.Remove(wl);
                await db.SaveChangesAsync();
            }

            return(RedirectToAction("Index"));
        }
        public async Task <WatchListPostDeleteDTO> DeleteWatchlistItem(string id, WatchListPostDeleteDTO watchListDeleteDTO)
        {
            if (watchListDeleteDTO == null)
            {
                throw new ArgumentNullException(nameof(watchListDeleteDTO));
            }

            try
            {
                WatchList watchlist = await _context.WatchLists
                                      .FirstOrDefaultAsync(w => w.UserId == id && w.MovieId == watchListDeleteDTO.MovieId).ConfigureAwait(false);

                _context.WatchLists.Remove(watchlist);

                await _context.SaveChangesAsync().ConfigureAwait(false);
            }
            catch (DbUpdateConcurrencyException)
            {
                if (await UserExists(id).ConfigureAwait(false) == false)
                {
                    return(null);
                }
                else
                {
                    throw;
                }
            }
            return(new WatchListPostDeleteDTO()
            {
                UserId = id,
                MovieId = watchListDeleteDTO.MovieId
            });
        }
        //Clear WatchList Service
        public void ClearWatchList(HttpContextBase httpContext)
        {
            WatchList watchList = GetWatchList(httpContext, false);

            watchList.WatchListItems.Clear();
            watchListContext.Commit();
        }
Example #21
0
        /// <summary>
        /// Button event that adds an item to a Watchlist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddToWatchList_Click(object sender, EventArgs e)
        {
            bool          success  = false;
            IQuoteManager qm       = new QuoteManager();
            string        symbol   = tbAddToWatchList.Text.Trim().ToUpper();
            string        listName = radioLists.SelectedValue;

            if (symbol.Length > 0)
            {
                // If it is valid, add it to the list
                if (qm.startWatching(symbol))
                {
                    IWatchList wl = new WatchList();
                    success = wl.AddToList(new Symbol(symbol), listName);
                    if (success)
                    {
                        setStatus(String.Format("{0} added to list \"{1}.\"", symbol, listName), true);
                    }
                    else
                    {
                        setStatus(String.Format("{0} could not be added to \"{1}.\"", symbol, listName), false);
                    }
                    strategy.startWatching(symbol);
                    updateList(true);
                }
                else                 // If it's not, display invalid symbol message.
                {
                    setStatus("Invalid symbol.", false);
                }
            }
            else
            {
                setStatus("Stock symbol cannot be blank.", false);
            }
        }
        public async Task <IActionResult> Create([FromBody] WatchListCreateModel model)
        {
            if (!await IsValidAsync(model.AssetPairIds) ||
                string.IsNullOrEmpty(model.Name))
            {
                return(BadRequest());
            }

            var watchlists = await GetAllWatchlists();

            if (watchlists.Any(item => item.Name == model.Name))
            {
                return(BadRequest());
            }

            var watchList = new WatchList
            {
                Id       = Guid.NewGuid().ToString(),
                Name     = model.Name,
                Order    = model.Order,
                AssetIds = model.AssetPairIds.ToList()
            };

            var result = await _assetsHelper.AddCustomWatchListAsync(_requestContext.ClientId, watchList);

            return(Ok(result.ToApiModel()));
        }
Example #23
0
        public async Task <IActionResult> PutWatchList([FromRoute] int id, [FromBody] WatchList watchList)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != watchList.WatchId)
            {
                return(BadRequest());
            }

            _context.Entry(watchList).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WatchListExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Example #24
0
		private void SaveMenuItem_Click(object sender, EventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(_currentFileName))
			{
				var watches = new WatchList(MemoryDomains, Emu.SystemId) { CurrentFileName = _currentFileName };
				for (var i = 0; i < _searches.Count; i++)
				{
					watches.Add(_searches[i]);
				}

				if (!string.IsNullOrWhiteSpace(watches.CurrentFileName))
				{
					if (watches.Save())
					{
						_currentFileName = watches.CurrentFileName;
						MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";
						Settings.RecentSearches.Add(watches.CurrentFileName);
					}
				}
				else
				{
					var result = watches.SaveAs(GetWatchSaveFileFromUser(CurrentFileName()));
					if (result)
					{
						MessageLabel.Text = $"{Path.GetFileName(_currentFileName)} saved";
						Settings.RecentSearches.Add(watches.CurrentFileName);
					}
				}
			}
		}
Example #25
0
        public async Task <IActionResult> Edit(int id, [Bind("WatchId,ItemId,UserId")] WatchList watchList)
        {
            if (id != watchList.WatchId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(watchList);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WatchListExists(watchList.WatchId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(watchList));
        }
Example #26
0
        public IActionResult Add(WatchlistVM model)
        {
            WatchList watchList = new WatchList();

            watchList.MovieID = model.movieid;
            watchList.UserID  = Convert.ToInt32(TempData["ID"]);

            UserPageVM user = new UserPageVM();

            user.UserWatch = _context.WatchLists.Include(x => x.Movie).Where(q => q.UserID == Convert.ToInt32(TempData["ID"])).ToList().ToPagedList();

            int counter = 0;

            foreach (var item in user.UserWatch)
            {
                if (model.movieid == item.MovieID)
                {
                    counter++;
                }
            }


            if (counter == 0)
            {
                _context.WatchLists.Add(watchList);
                _context.SaveChanges();

                return(Redirect("/watchlist"));
            }

            return(Redirect("/watchlist"));
        }
        public async Task HandleWithValidUpdateRequestCallUpdateAsExpectedResult()
        {
            // Arrange          
            var watchListEntity = new WatchList { MovieId = 299536, Comments = "Avengers: Infinity War is good" };
            var watchListModel = new WatchListModel { MovieId = 299536, Comments = "Avengers: Infinity is good" };

            var config = new MapperConfiguration(m => { m.CreateMap<WatchList, WatchListModel>(); });
            var mapper = new Mapper(config);

            repository = new Mock<IRepository>();
            repository.Setup(m => m.Get<WatchList>(It.IsAny<int>()))
              .Returns(watchListEntity);

            updateWatchList = new UpdateWatchList(repository.Object, mapper);
            updateWatchListRequest = new UpdateWatchListRequest(watchListModel);

            // Act
            CancellationToken cancellationToken;
            var result = await updateWatchList.Handle(updateWatchListRequest, cancellationToken);

            // Assert  
            Assert.NotNull(result);
            Assert.Equal(watchListModel.Comments, result.Comments);
            Assert.Equal(watchListModel.MovieId, result.MovieId);
        }
Example #28
0
        /// <summary>
        /// Button event that removes an item from a Watchlist.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnRemove_Click(object sender, EventArgs e)
        {
            bool   success  = false;
            string symbol   = ((Button)sender).Attributes["Symbol"];
            string listName = ((Button)sender).Attributes["ListName"];

            if (symbol.Length > 0 && listName.Length > 0)
            {
                IWatchList wl = new WatchList();
                success = wl.RemoveFromList(new Symbol(symbol), listName);

                if (success)
                {
                    setStatus(String.Format("{0} removed from list \"{1}.\"", symbol, listName), true);
                }

                //check if all instances of that symbol are removed before strategy stops watching it
                TraderContext db = new TraderContext();
                if (db.WatchListItems.Where(x => x.SymbolName.Equals(symbol)).Count() == 0 && db.Positions.Where(x => x.SymbolName.Equals(symbol) && x.status == AlgoTrader.Interfaces.positionStatus.Open).Count() == 0)
                {
                    strategy.stopWatching(symbol);
                }
            }
            updateList(true);
        }
Example #29
0
        /// <summary>
        /// Deletes an existing watchlist with its connections
        /// </summary>
        /// <param name="watchlistID">the id of the existing watchlist</param>
        public void deleteWatchlist(int watchlistID)
        {
            if (ConnectionState == true)
            {
                WatchList item = (from mp in db.WatchList
                                  where mp.WatchListID == watchlistID
                                  select mp).First();

                if (item != null)
                {
                    var stocksMap = (from mp in db.StocksMap
                                     where mp.CategoryID == watchlistID
                                     where mp.Category == 'w'
                                     select mp);

                    if (stocksMap.Any())
                    {
                        db.StocksMap.DeleteAllOnSubmit(stocksMap);
                    }

                    db.WatchList.DeleteOnSubmit(item);
                }
                db.SubmitChanges();
            }
        }
Example #30
0
        public async Task <IActionResult> Edit(int id, [Bind("WatchListId,WatchListName,PupilId")] WatchList watchList)
        {
            if (id != watchList.WatchListId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(watchList);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!WatchListExists(watchList.WatchListId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PupilId"] = new SelectList(_context.Users, "Id", "Id", watchList.PupilId);
            return(View(watchList));
        }
Example #31
0
		public void Setup()
		{
			var provider = new MockConnectionProvider (SocialProtocol.Instance);
			provider.ConnectionMade += (sender, args) => server = new ConnectionBuffer (args.Connection);
			provider.Start (MessageTypes.Reliable);

			var c = new MockClientConnection (provider);
			client = new ConnectionBuffer (c);

			clientContext = new SerializationContext (c, new Dictionary<byte, Protocol> { { 2, SocialProtocol.Instance } });

			var context = new TempestClient (c, MessageTypes.Reliable);
			context.ConnectAsync (new Target (Target.LoopbackIP, 1)).Wait();

			list = new WatchList (context);
		}
Example #32
0
        public void WatchListTriggersClear()
        {
            var wl = new WatchList<int>("carp");
            bool triggered = false;

            wl.AddRangeInternal(new int[] { 1, 2, 3 });

            wl.OnCollectionChanged += new CollectionChanged<int>(delegate(string name, IEnumerable<int> collection)
            {
                triggered = true;
            });

            wl.Clear();

            Assert.IsTrue(triggered);
        }
Example #33
0
        public void WatchListTriggersIndexer()
        {
            var wl = new WatchList<int>("carp");
            bool triggered = false;

            wl.AddInternal(1);
            wl.AddInternal(2);

            wl.OnCollectionChanged += new CollectionChanged<int>(delegate(string name, IEnumerable<int> collection)
            {
                triggered = true;
            });

            wl[1] = 3;

            Assert.IsTrue(triggered);
            Assert.IsTrue(wl[1] == 3);
        }
Example #34
0
        public void WatchListTriggersInsert()
        {
            var wl = new WatchList<int>("carp");
            bool triggered = false;

            wl.AddInternal(1);
            wl.AddInternal(2);

            wl.OnCollectionChanged += new CollectionChanged<int>(delegate(string name, IEnumerable<int> collection)
            {
                triggered = true;
            });

            var l = wl as IList<int>;
            l.Insert(0, 3);

            Assert.IsTrue(triggered);
            triggered = false;

            wl.InsertRange(0, new int[] { 4, 5, 6, 7, 8 });

            Assert.IsTrue(triggered);
        }
Example #35
0
        private void SaveAsMenuItem_Click(object sender, EventArgs e)
        {
            var watches = new WatchList(MemoryDomains, _settings.Domain, Emu.SystemId) { CurrentFileName = _currentFileName };
            for (var i = 0; i < _searches.Count; i++)
            {
                watches.Add(_searches[i]);
            }

            if (watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(watches.CurrentFileName)))
            {
                _currentFileName = watches.CurrentFileName;
                MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
                Settings.RecentSearches.Add(watches.CurrentFileName);
            }
        }
Example #36
0
        private void NewRamWatch_Load(object sender, EventArgs e)
        {
            TopMost = Settings.TopMost;
            _watches = new WatchList(_memoryDomains, _memoryDomains.MainMemory, _emu.SystemId);
            LoadConfigSettings();
            RamWatchMenu.Items.Add(Settings.Columns.GenerateColumnsMenu(ColumnToggleCallback));
            UpdateStatusBar();

            PokeAddressToolBarItem.Enabled =
                FreezeAddressToolBarItem.Enabled =
                SelectedIndices.Any() &&
                SelectedWatches.All(w => w.Domain.CanPoke());
        }
Example #37
0
        public void Restart()
        {
            if ((!IsHandleCreated || IsDisposed) && !Global.Config.DisplayRamWatch)
            {
                return;
            }

            if (_watches != null && !string.IsNullOrWhiteSpace(_watches.CurrentFileName))
            {
                _watches.RefreshDomans(_memoryDomains, _memoryDomains.MainMemory);
                _watches.Reload();
                SetPlatformAndMemoryDomainLabel();
                UpdateStatusBar();
            }
            else
            {
                _watches = new WatchList(_memoryDomains, _memoryDomains.MainMemory, _emu.SystemId);
                NewWatchList(true);
            }
        }
Example #38
0
		private void SaveMenuItem_Click(object sender, EventArgs e)
		{
			if (!string.IsNullOrWhiteSpace(_currentFileName))
			{
				var watches = new WatchList(_settings.Domain) { CurrentFileName = _currentFileName };
				for (var i = 0; i < _searches.Count; i++)
				{
					watches.Add(_searches[i]);
				}

				if (!string.IsNullOrWhiteSpace(watches.CurrentFileName))
				{
					if (watches.Save())
					{
						_currentFileName = watches.CurrentFileName;
						MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
					}
				}
				else
				{
					var result = watches.SaveAs(ToolHelpers.GetWatchSaveFileFromUser(watches.CurrentFileName));
					if (result)
					{
						MessageLabel.Text = Path.GetFileName(_currentFileName) + " saved";
						Global.Config.RecentWatches.Add(watches.CurrentFileName);
					}
				}
			}
		}
Example #39
0
		public void LoadWatchFile(FileInfo file, bool append, bool truncate = false)
		{
			if (file != null)
			{
				if (!truncate)
				{
					_currentFileName = file.FullName;
				}

				var watches = new WatchList(_settings.Domain);
				watches.Load(file.FullName, append);

				var watchList = watches.Where(x => !x.IsSeparator);
				var addresses = watchList.Select(x => x.Address ?? 0).ToList();

				if (truncate)
				{
					SetRemovedMessage(addresses.Count);
					_searches.RemoveSmallWatchRange(watchList);
				}
				else
				{
					_searches.AddRange(addresses, append);
					MessageLabel.Text = file.Name + " loaded";
				}

				UpdateList();
				Global.Config.RecentSearches.Add(file.FullName);

				if (!append && !truncate)
				{
					_searches.ClearHistory();
				}

				ToggleSearchDependentToolBarItems();
			}
		}