//evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString);
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string texto = "";
            string texto1 = "";

            if (NavigationContext.QueryString.TryGetValue("name", out texto))
                this.name = texto;
            if (NavigationContext.QueryString.TryGetValue("uri", out texto1))
                this.uri = texto1;

            //---------------------------------------------------------------------------------------------------------

            using (evolucionBrowserDataContext context = new evolucionBrowserDataContext(ConnectionString))
            {
                if (!string.IsNullOrEmpty(name) && !string.IsNullOrEmpty(uri)){
                        Favorite fav = new Favorite { Name = name, Uri = uri };
                        context.Favorites.InsertOnSubmit(fav);
                        context.SubmitChanges();
                }

                // Define query to fetch all customers in database.
                var favv = from Favorite todo in context.Favorites
                           select todo;

                // Execute query and place results into a collection.
                aux = new ObservableCollection<Favorite>(favv);
                listBox.ItemsSource = aux.ToList();
            }
        }
 public MoveFavorite(Favorite favorite, FavoritesFolder oldFolder)
 {
     InitializeComponent();
     label1.Text = favorite.Name;
     _favorite = favorite;
     _oldFolder = oldFolder;
 }
Example #3
0
 public static void AddFavorite(Favorite title)
 {
     lock (Favorites.List)
     {
         Favorites._List.Add(title);
         Favorites.Save();
     }
 }
Example #4
0
 public NewFolder(Favorite favorite)
 {
     InitializeComponent();
     _favorite = favorite;
     Text = "Rename Favorite";
     _rename = true;
     textBox1.Text = favorite.Name;
 }
        public FavoriteViewModel Post(FavoriteViewModel favoriteViewModel)
        {
            var recipie = _unitOfWork.Recipies.Get(_ => _.Id == favoriteViewModel.RecipeId);
            var user = _unitOfWork.Users.Get(_ => _.Id == favoriteViewModel.UserId);

            var favorite = new Favorite {Created = DateTime.Now, Id = Guid.NewGuid(), Recipe = recipie, User = user};
            _unitOfWork.Favorites.Add(favorite);
            _unitOfWork.Commit();

            var viewModel = Mapper.Map<Favorite, FavoriteViewModel>(favorite);
            viewModel.RecipeId = favorite.Recipe.Id;

            return viewModel;
        }
Example #6
0
 public IHttpActionResult GetUniqueFavorite(int id, int favoriteid)
 {
     try
     {
         SpecialistManager manager  = new SpecialistManager();
         Favorite          favorite = manager.FavoriteUnique(favoriteid);
         if (favorite.specialist.id == id)
         {
             return(Ok(favorite));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
        private async void Accept(object sender, RoutedEventArgs e)
        {
            if (!Creatable)
            {
                return;
            }

            Favorite favorite = new Favorite()
            {
                Name        = location.Name,
                Address     = location.Address,
                Description = location.Description,
                Collection  = collection,
                Symbol      = location.Symbol,
                Location    = Location.Location,
                Timestamp   = DateTime.Now
            };

            // Its a new collection name, delete it from the old folder ...
            if (location is Favorite && collection != collectionBuffer)
            {
                await(location as Favorite).Delete();
            }

            // ... and create a new Favorite in the right collection folder
            await favorite.SaveToFile(collection);

            // Set this as the new location
            Location = favorite;

            // Reset the Buffer
            locationBuffer = location;

            // Recreate the CommandBar
            CreateAppBarButtons();

            //VisualStateManager.GoToState(this, "Default", true);

            // Because we added a State with an OnGoBackAction for this
            NavigationManager.Current.NavigateBack();
        }
        public async Task <IActionResult> PutFavorite(int id, Favorite favorite)
        {
            var authorizedUser = await Authentication.GetAuthenticatedUserAsync(_context, Request);

            if (authorizedUser.Result is UnauthorizedResult)
            {
                return(Unauthorized());
            }

            if (authorizedUser.Value == null)
            {
                return(Unauthorized());
            }
            if (favorite.ArtistId != authorizedUser.Value.Id)
            {
                return(Unauthorized());
            }
            if (id != favorite.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!FavoriteExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }
            return(Ok());
        }
Example #9
0
        public ActionResult MakeFavorite(int recipeId, string userName)
        {
            var user = User.Identity;

            if (userName == null || user == null || user.Name != userName)
            {
                return(View("Login"));
            }

            var recipe = _context.Recipe.Find(recipeId);

            if (recipe == null)
            {
                return(View("Error"));
            }

            var      userObj  = _context.Users.FirstOrDefault(u => u.UserName == userName);
            Favorite favorite = null;

            if (userObj != null)
            {
                favorite = _context.Favorite.SingleOrDefault(f => f.RecipeID == recipeId && f.UserID == userObj.Id);
            }
            var isFavorite = false;

            if (favorite != null)
            {
                _context.Favorite.Remove(favorite);
            }
            else
            {
                isFavorite      = true;
                favorite        = new Favorite();
                favorite.User   = userObj;
                favorite.Recipe = recipe;
                _context.Favorite.Add(favorite);
            }
            _context.SaveChanges();

            return(Json(new { success = true, favorite = isFavorite }));
        }
Example #10
0
        private void PopulateGeneralOptions()
        {
            string pingIntervalUnits;
            int    pingIntervalDivisor;
            int    pingInterval = ApplicationOptions.PingInterval;
            int    pingTimeout  = ApplicationOptions.PingTimeout;

            if (ApplicationOptions.PingInterval >= 3600000 && ApplicationOptions.PingInterval % 3600000 == 0)
            {
                pingIntervalUnits   = "hours";
                pingIntervalDivisor = 3600000;
            }
            else if (ApplicationOptions.PingInterval >= 60000 && ApplicationOptions.PingInterval % 60000 == 0)
            {
                pingIntervalUnits   = "minutes";
                pingIntervalDivisor = 60000;
            }
            else
            {
                pingIntervalUnits   = "seconds";
                pingIntervalDivisor = 1000;
            }

            pingInterval /= pingIntervalDivisor;
            pingTimeout  /= 1000;

            PingInterval.Text      = pingInterval.ToString();
            PingTimeout.Text       = pingTimeout.ToString();
            AlertThreshold.Text    = ApplicationOptions.AlertThreshold.ToString();
            PingIntervalUnits.Text = pingIntervalUnits;

            // Get startup mode settings.
            InitialProbeCount.Text      = ApplicationOptions.InitialProbeCount.ToString();
            InitialColumnCount.Text     = ApplicationOptions.InitialColumnCount.ToString();
            StartupMode.SelectedIndex   = (int)ApplicationOptions.InitialStartMode;
            InitialFavorite.ItemsSource = Favorite.GetTitles();
            InitialFavorite.Text        =
                (ApplicationOptions.InitialFavorite == null)
                ? string.Empty
                : ApplicationOptions.InitialFavorite;
        }
Example #11
0
        private void RefreshFavorites()
        {
            var favoritesList = Favorite.GetFavoriteTitles();

            // Clear existing favorites menu.
            for (int i = mnuFavorites.Items.Count - 1; i > 2; --i)
            {
                mnuFavorites.Items.RemoveAt(i);
            }

            // Load favorites.
            foreach (var fav in favoritesList)
            {
                var menuItem = new MenuItem();
                menuItem.Header = fav;
                menuItem.Click += (s, r) =>
                {
                    ClearAllPingItems();

                    var selectedFavorite = s as MenuItem;
                    var favorite         = Favorite.GetFavoriteEntry(selectedFavorite.Header.ToString());
                    if (favorite.Hostnames.Count < 1)
                    {
                        AddHostMonitor(1);
                    }
                    else
                    {
                        AddHostMonitor(favorite.Hostnames.Count);
                        for (int i = 0; i < favorite.Hostnames.Count; ++i)
                        {
                            _pingItems[i].Hostname = favorite.Hostnames[i].ToUpper();
                            PingStartStop(_pingItems[i]);
                        }
                    }

                    sliderColumns.Value = favorite.ColumnCount;
                };

                mnuFavorites.Items.Add(menuItem);
            }
        }
Example #12
0
        public async Task <IActionResult> Delete(string repoId, string username)
        {
            //Add the id repository to favorites
            if (string.IsNullOrEmpty(repoId))
            {
                return(Ok(new { Success = false }));
            }

            Favorite favorite = new Favorite()
            {
                repoId   = long.Parse(repoId),
                username = username
            };

            string res = await DBHelper.DeleteFavorite(favorite);

            return(Ok(new
            {
                Success = true
            }));
        }
Example #13
0
 public IHttpActionResult PostFavorite(int id, [FromBody] Favorite favorite)
 {
     try
     {
         FavoriteManager manager = new FavoriteManager();
         favorite.specialist.id = id;
         Favorite result = manager.Insertar(favorite);
         if (result != null)
         {
             return(Created(new Uri(Url.Link(ViewRouteName, new { id = result.specialist.id })), result));
         }
         else
         {
             return(BadRequest());
         }
     }
     catch (Exception e)
     {
         return(NotFound());
     }
 }
        //Favorite Controller

        public ActionResult Addtofavorite(int id)
        {
            var userId = User.Identity.GetUserId();

            var check = db.Favorites.Where(a => a.ExpirimentId == id && a.ApplicationUserId == userId).ToList();

            if (check.Count < 1)
            {
                var favorie = new Favorite();
                favorie.ExpirimentId      = id;
                favorie.ApplicationUserId = userId;
                db.Favorites.Add(favorie);
                db.SaveChanges();
                TempData["Validation"] = "Expiriment Ajouter dans favorite ";
            }
            else
            {
                TempData["Validation"] = "Expiriment existe D'éja dans favorite";
            }
            return(RedirectToAction("FavoriteIndex"));
        }
Example #15
0
        public async Task AddToFavoriteAsync(string userId, int autopartId)
        {
            var favoriteExistingEntity = this.favoritesRepository.AllAsNoTracking().Where(x => x.UserId == userId && x.AutopartId == autopartId).FirstOrDefault();

            if (favoriteExistingEntity != null)
            {
                this.favoritesRepository.HardDelete(favoriteExistingEntity);
            }
            else
            {
                var favoriteEntity = new Favorite
                {
                    UserId     = userId,
                    AutopartId = autopartId,
                };

                await this.favoritesRepository.AddAsync(favoriteEntity);
            }

            await this.favoritesRepository.SaveChangesAsync();
        }
        public async Task DeleteFavorite(string id)
        {
            try
            {
                Favorite favorite = await _context.Favorites
                                    .Where(x => x.Id == Guid.Parse(id))
                                    .FirstOrDefaultAsync();

                _context.Favorites.Remove(favorite);

                await _context.SaveChangesAsync();
            }
            catch (MovieMindException)
            {
                throw;
            }
            catch (Exception e)
            {
                throw new DatabaseException(e.InnerException.Message, this.GetType().Name, "DeleteFavorite", "400");
            }
        }
Example #17
0
        private async Task <IActionResult> CreateFavorite()
        {
            var name = User.FindFirstValue(ClaimTypes.Name);

            if (name == null)
            {
                return(BadRequest());
            }
            var user = await _context.User.FirstOrDefaultAsync(a => a.UserName == name);

            var userId      = user.Id;
            var newFavorite = new Favorite
            {
                UserId = userId
            };

            _context.Favorites.Add(newFavorite);
            await _context.SaveChangesAsync();

            return(Ok());
        }
Example #18
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            if (Favorites.SelectedIndex < 0)
            {
                return;
            }

            var dialogWindow = new DialogWindow(
                DialogWindow.DialogIcon.Warning,
                "Confirm Delete",
                $"Are you sure you want to remove {Favorites.SelectedItem.ToString()} from your favorites?",
                "Remove",
                true);

            dialogWindow.Owner = this;
            if (dialogWindow.ShowDialog() == true)
            {
                Favorite.Delete(Favorites.SelectedItem.ToString());
                RefreshFavoriteList();
            }
        }
Example #19
0
        private void LoadFavorites()
        {
            // Clear existing favorites menu.
            for (int i = FavoritesMenu.Items.Count - 1; i > 2; --i)
            {
                FavoritesMenu.Items.RemoveAt(i);
            }

            // Load favorites.
            foreach (var fav in Favorite.GetTitles())
            {
                var menuItem = new MenuItem();
                menuItem.Header = fav;
                menuItem.Click += (s, r) =>
                {
                    LoadFavorite((s as MenuItem).Header.ToString());
                };

                FavoritesMenu.Items.Add(menuItem);
            }
        }
Example #20
0
        public async Task <Favorite> DeleteFavoriteAsync(int Id)
        {
            Favorite responseFavorite = null;

            try
            {
                var response = await Client.DeleteAsync(this.BaseUrl + "/api/Favorites/" + Id);

                if (response.IsSuccessStatusCode)
                {
                    var responseContent = await response.Content.ReadAsStringAsync();

                    responseFavorite = JsonConvert.DeserializeObject <Favorite>(responseContent);
                }
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine("Exception in RestService.DeleteEmployeeAsync: " + e);
            }
            return(responseFavorite);
        }
        public async Task <ActionResult <Favorite> > PostFavorite(Favorite favorite)
        {
            var user = await _userManager.GetUserAsync(User);

            var existFavorite = await _context.Favorite.FirstOrDefaultAsync(f => f.ItemId == favorite.ItemId && !f.Deleted && f.UserId == user.Id);

            if (null != existFavorite)
            {
                existFavorite.Deleted  = true;
                existFavorite.Modified = DateTime.Now;
                await _context.SaveChangesAsync();

                return(Ok(new { status = 1, message = "☆" }));
            }

            favorite.UserId = user.Id;
            _context.Favorite.Add(favorite);
            await _context.SaveChangesAsync();

            return(Ok(new { status = 1, message = "★" }));
        }
        /// <summary>
        /// Adds the specified restaurant to the specified user's Favorites
        /// Throws an exception if specified user or restraunt is not found in DB
        /// Also throws exception if Favorite list already exists for that user
        /// Must still call Save() after to persist changes to DB
        /// </summary>
        /// <param name="username">string containing user's username</param>
        /// <param name="restaurantId">int containing restaurant's ID number</param>
        /// <param name="rRepo">RestaurantRepo object, required for validation to ensure the given restraunt exists in our DB</param>
        public async Task AddRestaurantToFavoritesAsync(string username, string restaurantId, RestaurantRepo rRepo)
        {
            var contains = await DBContainsUsernameAsync(username);

            if (!contains)
            {
                throw new DbUpdateException($"Username '{username}' not found.", new NotSupportedException());
            }
            contains = await rRepo.DBContainsRestaurantAsync(restaurantId);

            if (!contains)
            {
                throw new DbUpdateException($"Restaurant ID '{restaurantId}' not found.", new NotSupportedException());
            }
            Favorite fav = new Favorite()
            {
                Username = username, RestaurantId = restaurantId
            };

            _db.Add(fav);
        }
        //lets you do a authorized command wherein you can unfavorite a game using its gameid
        public IHttpActionResult DeleteFavorite(Guid gameId)
        {
            using (var context = new gamebase1Entities())
            {
                var identity = User.Identity as ClaimsIdentity; //each authorized request merong username na nakaattach sa mga request so need natin i extract mga yun at i match sa db
                var claims   = from c in identity.Claims        //extracting the username in var identity
                               select new
                {
                    subject = c.Subject.Name,
                    type    = c.Type,
                    value   = c.Value
                };
                var        userName = claims.ToList()[0].value.ToString(); //converting to string
                AspNetUser user     = context.AspNetUsers.Where(u => u.UserName == userName).Single();

                Favorite selectedGame = context.Favorites.Where(u => u.GameID == gameId).FirstOrDefault(); //performing transaction
                context.Favorites.Remove(selectedGame);
                context.SaveChanges();                                                                     //saving to db
            }
            return(Ok());
        }
Example #24
0
        public ActionResult CreateCustom(Favorite data)
        {
            string filename = "";

            if (Request.Files["fuImage"].HasFile())
            {
                filename   = Request.Files["fuImage"].FileName;
                data.Photo = filename;
            }

            int FavoriteID = new Favorites().Add(data);

            if (!string.IsNullOrEmpty(filename))
            {
                string originalFile = Server.MapPath(@"/img/favorites/" + FavoriteID.ToString() + "/");
                Directory.CreateDirectory(originalFile);
                Request.Files["fuImage"].SaveAs(originalFile + filename);
            }

            return(Redirect("/admin/favorites"));
        }
Example #25
0
        private void Remove_Click(object sender, RoutedEventArgs e)
        {
            if (Favorites.SelectedIndex < 0)
            {
                return;
            }

            var dialogWindow = new DialogWindow(
                DialogWindow.DialogIcon.Warning,
                Strings.DialogTitle_ConfirmDelete,
                $"{Strings.ManageFavorites_Warn_DeleteA} {Favorites.SelectedItem} {Strings.ManageFavorites_Warn_DeleteB}",
                Strings.DialogButton_Remove,
                true);

            dialogWindow.Owner = this;
            if (dialogWindow.ShowDialog() == true)
            {
                Favorite.Delete(Favorites.SelectedItem.ToString());
                RefreshFavoriteList();
            }
        }
        public IActionResult AddToFavorite(string name, int rating, string id)
        {
            Favorite favorite = new Favorite
            {
                Rank        = rating,
                StartupName = name,
                StartupId   = id,
                UserId      = User.FindFirst(ClaimTypes.NameIdentifier).Value
            };

            if (_context.Favorite.Where(x => (x.StartupName == name) && (x.UserId == User.FindFirst(ClaimTypes.NameIdentifier).Value)).ToList().Count > 0)
            {
                return(RedirectToAction("Favorites"));
            }
            if (ModelState.IsValid)
            {
                _context.Favorite.Add(favorite);
                _context.SaveChanges();
            }
            return(RedirectToAction("Favorites"));
        }
        public void AddUser_AddsUserToFavorite_User()
        {
            //Arrange
            Favorite testFavorite = new Favorite("Pok Pok", "3226 SE Division Street 97202", "https://www.zomato.com/portland/pok-pok-richmond/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop", "https://www.zomato.com/portland/pok-pok-richmond/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop", 45.5046, -122.632, 35, "Thai");

            testFavorite.Save();
            User testUser = new User("test-user", "password");

            testUser.Save();
            testUser.Edit(2, 25, "hello");

            //Act
            testFavorite.AddUser(testUser);
            List <User> result   = testFavorite.GetUser();
            List <User> testList = new List <User> {
                testUser
            };

            //Assert
            CollectionAssert.AreEqual(testList, result);
        }
        public async Task <ActionResult <Favorite> > PostFavorite(Favorite favorite)
        {
            _context.Favorites.Add(favorite);
            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateException)
            {
                if (FavoriteExists(favorite.FavoritingUserId))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtAction("GetFavorite", new { id = favorite.FavoritingUserId }, favorite));
        }
        public void AddFavoriteForUser(Guid userId, Favorite favorite)
        {
            var user = _userRepository.GetUser(userId);

            if (user != null)
            {
                if (FavoriteExists(userId, favorite.CarparkId))
                {
                    throw new AppException($"This carpark {favorite.CarparkId} already exists as a favorite for user {userId}!");
                }
                else
                {
                    if (favorite.Id == Guid.Empty)
                    {
                        favorite.Id = Guid.NewGuid();
                    }

                    user.Favorites.Add(favorite);
                }
            }
        }
Example #30
0
        public async Task <int> CreateOrRemoveFavoriteAsync(int listingId, int userId)
        {
            Favorite favorite = await _repository.FavoriteRepo
                                .FindByCondition(x => x.ListingId == listingId && x.UserId == userId)
                                .SingleOrDefaultAsync();

            if (favorite is null)
            {
                favorite           = new Favorite();
                favorite.ListingId = listingId;
                favorite.UserId    = userId;

                await _repository.FavoriteRepo.CreateAsync(favorite);
            }
            else
            {
                _repository.FavoriteRepo.Delete(favorite);
            }

            return(await _repository.SaveChangesAsync());
        }
Example #31
0
        public Object AddToFavoriteEvents(Favorite favoriteEvent)
        {
            SqlConnection conn    = new SqlConnection(connString);
            string        command = "INSERT INTO Favorites (UserID, EventID) ";

            command += "VALUES (@userID, @eventID)";

            int result = conn.Execute(command, new
            {
                userID  = favoriteEvent.UserID,
                eventID = favoriteEvent.EventID,
            });

            conn.Close();

            return(new
            {
                result = result,
                success = result == 1 ? true : false
            });
        }
        public IActionResult AddComment(int id, string comment)
        {
            Favorite found = _context.Favorite.Find(id);

            if (found != null)
            {
                found.PrivateComments       = comment;
                _context.Entry(found).State = EntityState.Modified;
                _context.Update(found);
                _context.SaveChanges();

                _context.Comments.Add(new Comments
                {
                    Comment    = comment,
                    FavoriteId = id
                });

                _context.SaveChanges();
            }
            return(RedirectToAction("Favorites"));
        }
Example #33
0
        public async void FavoriteControllerCreateTest()
        {
            DbContextOptions <LTBDBContext> options =
                new DbContextOptionsBuilder <LTBDBContext>()
                .UseInMemoryDatabase("Favorites")
                .Options;

            using (LTBDBContext context = new LTBDBContext(options))
            {
                FavoriteService TestService = new FavoriteService(context);
                Favorite        favorites   = new Favorite();
                favorites.UserID = 1;
                favorites.PetID  = 2;
                favorites.Notes  = "Did this test pass?";
                await TestService.CreateFavorite(favorites);

                var TestFavorite = await TestService.GetFavorite(1, 2);

                Assert.Equal("Did this test pass?", TestFavorite.Notes);
            }
        }
        public void Delete_DeletesfavoriteAssociationsFromDatabase_ItemList()
        {
            //Arrange
            User testUser = new User("test-user", "password");

            testUser.Save();
            testUser.Edit(2, 25, "hello");
            Favorite testFavorite = new Favorite("Pok Pok", "3226 SE Division Street 97202", "https://www.zomato.com/portland/pok-pok-richmond/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop", "https://www.zomato.com/portland/pok-pok-richmond/menu?utm_source=api_basic_user&utm_medium=api&utm_campaign=v2.1&openSwipeBox=menu&showMinimal=1#tabtop", 45.5046, -122.632, 35, "Thai");

            testFavorite.Save();

            //Act
            testFavorite.AddUser(testUser);
            testFavorite.Delete();
            List <Favorite> resultUserFavorites = testUser.GetUserFavorite();
            List <Favorite> testUserFavorites   = new List <Favorite> {
            };

            //Assert
            CollectionAssert.AreEqual(testUserFavorites, resultUserFavorites);
        }
Example #35
0
        private void LoadFavorites()
        {
            // Clear existing favorites menu.
            for (int i = mnuFavorites.Items.Count - 1; i > 2; --i)
            {
                mnuFavorites.Items.RemoveAt(i);
            }

            // Load favorites.
            foreach (var fav in Favorite.GetTitles())
            {
                var menuItem = new MenuItem();
                menuItem.Header = fav;
                menuItem.Click += (s, r) =>
                {
                    RemoveAllProbes();

                    var selectedFavorite = s as MenuItem;
                    var favorite         = Favorite.GetContents(selectedFavorite.Header.ToString());
                    if (favorite.Hostnames.Count < 1)
                    {
                        AddProbe();
                    }
                    else
                    {
                        AddProbe(numberOfProbes: favorite.Hostnames.Count);
                        for (int i = 0; i < favorite.Hostnames.Count; ++i)
                        {
                            _ProbeCollection[i].Hostname = favorite.Hostnames[i].ToUpper();
                            _ProbeCollection[i].Alias    = _Aliases.ContainsKey(_ProbeCollection[i].Hostname) ? _Aliases[_ProbeCollection[i].Hostname] : null;
                            _ProbeCollection[i].StartStop();
                        }
                    }

                    ColumnCount.Value = favorite.ColumnCount;
                };

                mnuFavorites.Items.Add(menuItem);
            }
        }
        /// <summary>
        /// 즐겨찾기 생성
        /// </summary>
        /// <param name="product">제품</param>
        /// <param name="company">소유자 회사</param>
        /// <param name="ownerCode">소유자 코드</param>
        /// <param name="ownerKind">소유자 종류</param>
        /// <param name="content">즐겨찾기 내용</param>
        /// <returns></returns>
        public Favorite CreateFavorite(Product product, Company company, string ownerCode, ActorKinds ownerKind, string content)
        {
            product.ShouldNotBeNull("product");
            company.ShouldNotBeNull("company");
            ownerCode.ShouldNotBeWhiteSpace("owernCode");

            if(IsDebugEnabled)
                log.Debug(@"새로운 즐겨찾기 정보를 생성합니다... product={0}, company={1}, ownerCode={2}, ownerKind={3}, content={4}",
                          product, company, ownerCode, ownerKind, content);

            var favorite = new Favorite(product, company, ownerCode, ownerKind, content);
            return Repository<Favorite>.SaveOrUpdate(favorite);
        }
 private void detach_Favorites(Favorite entity)
 {
     this.SendPropertyChanging("Favorites");
     entity.Dealer = null;
 }
Example #38
0
		public static void AddFavoriteSession(Favorite favorite)
		{
            DAL.DataManager.SaveFavorite(favorite);
		}
 public void AddToFavorites(Favorite favorite)
 {
     base.AddObject("Favorites", favorite);
 }
 private void AssignStoresToFavorites(Favorite[] fileFavorites)
 {
     foreach (Favorite favorite in fileFavorites)
     {
         favorite.AssignStores(this.Security, this.groups);
     }
 }
 private Favorite LoadAndSaveToResult(Favorite source)
 {
     this.propertiesControl.LoadFrom(source);
     Favorite result = ProtocolOptionsPanelTests.CreateFavorite(this.groups);
     this.propertiesControl.SaveTo(result);
     return result;
 }
Example #42
0
    protected void FavoriteIndexChanged(object sender, EventArgs e)
    {
        try
        {
            DropDownList drop = (DropDownList)sender;
            long fId;
            long.TryParse(drop.Attributes["FavID"], out fId);
            string partCode = drop.Attributes["PC"];

            Favorite fav = PartDAO.GetFavorite(fId);

            if (string.IsNullOrEmpty(drop.SelectedValue))
            {
                PartDAO.DeleteFavorite(fav);
            }
            else
            {
                if (fav == null && UserHelper.IsDealer && !string.IsNullOrEmpty(partCode))
                {
                    fav = new Favorite() { DealerCode = UserHelper.DealerCode, Type = drop.Attributes["Type"], PartCode = partCode, PartType = drop.Attributes["PT"] };
                    PartDAO.PartDC.Favorites.InsertOnSubmit(fav);
                }
                if (fav != null) fav.Rank = int.Parse(drop.SelectedValue);
            }
        }
        catch (Exception ex) { AddErrorMsg(ex.Message); }
    }
 public static Favorite CreateFavorite(string path)
 {
     Favorite favorite = new Favorite();
     favorite.Path = path;
     return favorite;
 }
Example #44
0
        public int? AddFavorite(int favoriteUserId, int favoriteItemId, ItemType? favoriteItemType)
        {
            if (favoriteItemType == null)
            {
                favoriteItemType = itemRepository.ItemTypeForItemId(favoriteItemId);
            }

            int? itemId = itemRepository.GenerateItemId(ItemType.Favorite);
            if (itemId == null)
            {
                return null;
            }

            Favorite fav = new Favorite() { FavoriteId = itemId, FavoriteUserId = favoriteUserId, FavoriteItemId = favoriteItemId, FavoriteItemTypeId = (int)favoriteItemType };
            fav.TimeStamp = DateTime.UtcNow.ToUnixTime();

            this.database.InsertObject<Favorite>(fav);

            return itemId;
        }
Example #45
0
 public static void RemoveFavorite(Favorite item)
 {
     lock (List)
     {
         Favorites._List.Remove(item);
         Favorites.Save();
     }
 }
Example #46
0
 protected void ProcessFavorite(Favorite fav, bool used, string type, string partCode,string partType, string rank)
 {
     if (used)
     {
         var db = PartInfoDAO.PartDC;
         if (fav == null)
         {
             fav = new Favorite { DealerCode = UserHelper.DealerCode, Type = type, PartCode = partCode, PartType = partType };
             db.Favorites.InsertOnSubmit(fav);
         }
         int fRank;
         int.TryParse(rank, out fRank);
         fav.Rank = fRank;
     }
     else
     {
         PartDAO.PendingDeleteFavorite(fav);
     }
 }
Example #47
0
        public static void Load()
        {
            if (File.Exists(Favorites.FavoritesFile))
            {
                string jsonDoc = File.ReadAllText(FavoritesFile);

                try
                {
                    Favorites._List = new List<Favorite>(JsonConvert.DeserializeObject<List<Favorite>>(jsonDoc));
                }
                catch
                {
                    Favorites._List_old = new List<string>(JsonConvert.DeserializeObject<List<string>>(jsonDoc));

                    foreach (string old_fav in Favorites._List_old)
                    {
                        Favorite fav = new Favorite();
                        fav.Kind = Favorite.FavoriteKinds.ByBinaryName;
                        fav.SearchText = old_fav;
                        Favorites.AddFavorite(fav);
                    }
                }
            }
            else
            {
                Favorites.Save();
            }
        }
Example #48
0
 protected void star_Click(object sender, EventArgs e)
 {
     try
     {
         // Clicking the star TOGGLES favorites, meaning if it's there it'll be deleted and vice versa...
         Favorite favorite = Favorite.FindFirst(
             Expression.Eq("FavoredBy", Operator.Current),
             Expression.Eq("Question", _question));
         if (favorite != null)
             favorite.Delete();
         else
         {
             Favorite f = new Favorite();
             f.FavoredBy = Operator.Current;
             f.Question = _question;
             f.Save();
         }
         Highlight(star);
         SetCssClassForFavorite();
     }
     catch (Exception err)
     {
         ShowError(err.Message);
     }
 }
Example #49
0
 public IFavorite CreateFavorite()
 {
     var newItem = new Favorite();
     newItem.AssignStores(this.persistenceSecurity, this.groups);
     return newItem;
 }
 public void FavoriteValidationTest()
 {
     var favorite = new Favorite();
     favorite.Protocol = longText.Substring(0, 11);
     favorite.ServerName = longText;
     var results = Validations.Validate(favorite);
     Assert.AreEqual(3, results.Count(), "Some properties arent validated properly for Favorite");
 }
Example #51
0
 partial void UpdateFavorite(Favorite instance);
Example #52
0
 public RouteFavoredEvent(Favorite f)
 {
     this.mRouteId = f.Route_ID;
     this.mEventCreator = f.User_ID;
     this.mEventTime = DateTime.Now;
 }
Example #53
0
 partial void InsertFavorite(Favorite instance);
Example #54
0
 partial void DeleteFavorite(Favorite instance);