Exemple #1
0
 public ActionResult Finalize()
 {
     try
     {
         double price = 0;
         List <Domain.Model.Item> orderItemsList = new List <Domain.Model.Item>();
         foreach (var val in MyOrder.itemsInOrder)
         {
             orderItemsList.Add(RepoItem.GetItemById(val));
             price = price + RepoItem.GetItemById(val).Price;
         }
         Domain.Model.Order myNewOrder = new Domain.Model.Order
         {
             UserId = RepoPers.GetPeopleByName(MyOrder.Username).First().Id,
             Date   = DateTime.Now,
             Price  = price,
             Items  = orderItemsList
         };
         RepoOrd.AddOrder(myNewOrder);
         RepoOrd.Save();
         MyOrder.Username     = "";
         MyOrder.itemsInOrder = null;
     }
     catch
     {
         return(RedirectToAction("Index", "Home"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Exemple #2
0
 public ActionResult Order([FromRoute] int id, [Bind("LogInViewModel,Items,selectedItems")] ItemAnLogInViewModel viewModel)
 {
     try
     {
         if (ModelState.IsValid)
         {
             viewModel = (ItemAnLogInViewModel )TempData["Login"];
             var myOldItem = RepoItem.GetItemById(id);
             var myNewItem = new ItemViewModel
             {
                 ItemId          = myOldItem.Id,
                 ItemName        = myOldItem.Name,
                 ItemDescription = myOldItem.Description,
                 ItemPrice       = myOldItem.Price,
                 StoreName       = RepoStore.GetStoreById(myOldItem.StoreId).Name,
                 OrderId         = myOldItem.OrderId,
                 SellerName      = RepoSell.GetSellerById(myOldItem.SellerId).Name,
                 TopicName       = RepoTopi.GetTopicById(myOldItem.TopicId).Topic
             };
             viewModel.selectedItems.Add(myNewItem);
             viewModel.Items.Remove(viewModel.Items.Find(p => p.ItemId == myNewItem.ItemId));
         }
         return(View(viewModel));
     }
     catch
     {
         return(View(viewModel));
     }
 }
        public IActionResult Create([Bind("SellerName,Items,AverageReview")] SellerViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var seller = new Domain.Model.Seller
                    {
                        Id    = viewModel.SellerId,
                        Name  = viewModel.SellerName,
                        Items = RepoItem.GetItemsBySellerName(viewModel.SellerName)
                                .FindAll(p => p.SellerId == (RepoSell.GetSellersByName(viewModel.SellerName)
                                                             .First(p => p.Name == viewModel.SellerName).Id)),
                        Reviews = RepoRev.GetReviewBySellerName(viewModel.SellerName)
                                  .FindAll(p => p.SellerId == (RepoSell.GetSellersByName(viewModel.SellerName)
                                                               .First(p => p.Name == viewModel.SellerName).Id))
                    };

                    RepoSell.AddSeller(seller);
                    RepoSell.Save();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(viewModel));
            }
            catch
            {
                return(View(viewModel));
            }
        }
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // Allow saved page state to override the initial item to display
            if (pageState != null)
            {
                if (pageState.ContainsKey(ITEM_VIEW_MODEL))
                {
                    if (pageState[ITEM_VIEW_MODEL] != null)
                    {
                        this.itemViewModel = pageState[ITEM_VIEW_MODEL] as ItemViewModel;
                    }
                }
            }

            if (itemViewModel == null)
            {
                if (navigationParameter != null)
                {
                    repo          = navigationParameter as RepoItem;
                    itemViewModel = new ItemViewModel(repo);
                }
            }

            if (itemViewModel != null)
            {
                this.DataContext = itemViewModel;
            }
        }
        public IActionResult Create([Bind("LocationName")] StoreViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var store = new Domain.Model.Store
                    {
                        Id    = viewModel.StoreId,
                        Name  = viewModel.LocationName,
                        Items = RepoItem.GetItemsByStoreName(viewModel.LocationName)
                                .FindAll(p => p.StoreId == (RepoStore.GetStoresByName(viewModel.LocationName)
                                                            .First(p => p.Name == viewModel.LocationName).Id)),
                    };

                    RepoStore.AddStore(store);
                    RepoStore.Save();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(viewModel));
            }
            catch
            {
                return(View(viewModel));
            }
        }
        public IActionResult Edit([FromRoute] int id, [Bind("SellerName,Items,AverageReview")] SellerViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Domain.Model.Seller seller = RepoSell.GetSellerById(id);
                    seller.Name  = viewModel.SellerName;
                    seller.Items = RepoItem.GetItemsBySellerName(viewModel.SellerName)
                                   .FindAll(p => p.SellerId == (RepoSell.GetSellersByName(viewModel.SellerName)
                                                                .First(p => p.Name == viewModel.SellerName).Id));
                    seller.Reviews = RepoRev.GetReviewBySellerName(viewModel.SellerName)
                                     .FindAll(p => p.SellerId == (RepoSell.GetSellersByName(viewModel.SellerName)
                                                                  .First(p => p.Name == viewModel.SellerName).Id));
                    RepoSell.UpdateSeller(seller);
                    RepoSell.Save();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(viewModel));
            }
            catch (Exception)
            {
                return(View(viewModel));
            }
        }
        public IActionResult Create([Bind("TopicName")] TopicOptionViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var topic = new Domain.Model.TopicOption
                    {
                        Id    = viewModel.TopicOptionId,
                        Topic = viewModel.TopicName,
                        Items = RepoItem.GetItemsByTopicName(viewModel.TopicName)
                                // .FindAll(p => p.TopicId == (RepoTopi.GetTopicByName(viewModel.TopicName)
                                // .First(p => p.Topic == viewModel.TopicName).Id)),
                    };

                    RepoTopi.AddTopic(topic);
                    RepoTopi.Save();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(viewModel));
            }
            catch
            {
                return(View(viewModel));
            }
        }
Exemple #8
0
        public ActionResult ViewCart(int id = 0)
        {
            double price = 0;
            List <Domain.Model.Item> orderItemsList = new List <Domain.Model.Item>();

            foreach (var val in MyOrder.itemsInOrder)
            {
                orderItemsList.Add(RepoItem.GetItemById(val));
                price = price + RepoItem.GetItemById(val).Price;
            }
            if (id > 0)
            {
                MyOrder.itemsInOrder.Add(id);
                orderItemsList.Add(RepoItem.GetItemById(id));
                price = price + RepoItem.GetItemById(id).Price;
            }
            var viewModel = new DetailedOrderViewModel
            {
                PersonName    = MyOrder.Username,
                StoreName     = RepoStore.GetStoreById(RepoPers.GetPeopleByName(MyOrder.Username).First(p => p.Username.ToLower() == MyOrder.Username.ToLower()).StoreId).Name,
                DateOfOrder   = DateTime.Now,
                Price         = price,
                ItemList      = orderItemsList,
                SuggestedItem = GetSuggestedItem.Suggest(RepoItem, RepoStore, RepoOrd, RepoTopi, RepoSell, RepoPers, RepoRev, MyOrder)
            };

            return(View(viewModel));
        }
Exemple #9
0
    void populateRepoBrowserPage()
    {
        //Debug.Log("************* UIMANAGER.populateRepoBrowserPage " + songBrowserPageIndex);

        transform.Find("titleContainer").GetComponentInChildren <Text>().text = "Default Song Repo";

        int pageIndex = songBrowserPageIndex * ITEMS_PER_PAGE;

        //Debug.Log(browserItemNames.Count + " " + songList.Count + " " + pageIndex + " " + songBrowserPageIndex);

        for (int i = 0; i < ITEMS_PER_PAGE; i++)
        {
            if (songList.Count > pageIndex + i)
            {
                RepoItem item = songList[pageIndex + i];
                browserItemNames[i].text = item.type + "|" + item.name;
                browserItemButtonsInteract(browserItemNames[i].transform.parent, true);
            }
            else
            {
                browserItemNames[i].text = "---";
                browserItemButtonsInteract(browserItemNames[i].transform.parent, false);
            }
        }
        prevBrowserButton.interactable = songBrowserPageIndex > 0;
        nextBrowserButton.interactable = pageIndex + ITEMS_PER_PAGE < songList.Count;
    }
Exemple #10
0
        public bool AddRepoItem(RepoItem toAdd)
        {
            var request = new RestRequest(ServiceConstants.Repo, Method.POST)
                          .AddJsonBody(toAdd);
            var result = _client.Execute(request);

            return(result.IsSuccessful);
        }
        public RepoItem GetItem(int id)
        {
            RepoItem repo  = new RepoItem();
            var      query = this.repos.FirstOrDefault(i => i.id == id);

            repo = (RepoItem)query;
            return(repo);
        }
Exemple #12
0
        public ItemUnitTest()
        {
            dbContextOptions = new DbContextOptionsBuilder <ApplicationContext>()
                               .UseSqlServer(connectionString)
                               .Options;

            var context = new ApplicationContext(dbContextOptions);

            repository = new RepoItem(context);
        }
Exemple #13
0
        public Control RegisterControl(
            Control c, Func <object, LambdaAction> setValue, LambdaAction takeOverLambda = null)
        {
            // add item
            var it = new RepoItem();

            it.control        = c;
            it.setValueLambda = setValue;
            it.takeOverLambda = takeOverLambda;
            items.Add(c, it);

            // put callbacks accordingly
            if (c is TextBox)
            {
                var tb = c as TextBox;
                it.originalValue = "" + tb.Text;
                tb.TextChanged  += Tb_TextChanged;
                tb.KeyUp        += Tb_KeyUp;
            }

            if (c is Button)
            {
                var b = c as Button;
                b.Click += B_Click;
            }

            if (c is ComboBox)
            {
                var cb = c as ComboBox;
                it.originalValue = "" + cb.Text;
                cb.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                              new System.Windows.Controls.TextChangedEventHandler(Tb_TextChanged));
                if (!cb.IsEditable)
                {
                    // we need this event
                    cb.SelectionChanged += Cb_SelectionChanged;
                }
                if (cb.IsEditable)
                {
                    // add this for comfort
                    cb.KeyUp += Tb_KeyUp;
                }
            }

            if (c is CheckBox)
            {
                var cb = c as CheckBox;
                it.originalValue = cb.IsChecked;
                cb.Checked      += Cb_Checked;
                cb.Unchecked    += Cb_Checked;
            }

            return(c);
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            string value;

            if (NavigationContext.QueryString.TryGetValue("parameter", out value))
            {
                int      id   = Int32.Parse(value);
                RepoItem item = App.MainViewModel.GetItem(id);
                this.DataContext = item;
            }
        }
Exemple #15
0
        private void NavigateToPage(object parameter)
        {
            Frame    currentFrame = Window.Current.Content as Frame;
            RepoItem item         = (RepoItem)parameter;

            if (parameter != null)
            {
                currentFrame.Navigate(typeof(ItemDetails), parameter);
            }
            else
            {
                currentFrame.Navigate(typeof(ItemDetails));
            }
        }
        private void NavigateToPage(object parameter)
        {
            Frame    currentFrame = (Application.Current.RootVisual as PhoneApplicationFrame);
            RepoItem item         = (RepoItem)parameter;

            if (parameter != null)
            {
                currentFrame.Navigate(new Uri("/Page2.xaml?parameter=" + item.id, UriKind.Relative));
            }
            else
            {
                currentFrame.Navigate(new Uri("/Page2.xaml", UriKind.Relative));
            }
        }
Exemple #17
0
 public void parseRepoData(string[] listData)
 {
     //string[] fileContent = File.ReadAllLines(patternFilePaths[suffix]);
     foreach (string line in listData)
     {
         if (!string.IsNullOrWhiteSpace(line))
         {
             RepoItem repoSong = RepoItem.parse(line);
             if (repoSong != null)
             {
                 songList.Add(repoSong);
             }
         }
     }
 }
        public ActionResult Delete(int id, [BindNever] IFormCollection collection)
        {
            try
            {
                RepoItem.DeleteItemByTopicId(id);
                RepoTopi.DeleteTopicById(id);
                RepoTopi.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, [BindNever] IFormCollection collection)
        {
            try
            {
                RepoRev.DeleteReviewBySellerId(id);
                RepoItem.DeleteItemBySellerId(id);
                RepoSell.DeleteSellerById(id);
                RepoSell.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public ActionResult Delete(int id, [BindNever] IFormCollection collection)
        {
            try
            {
                RepoPers.DeletePeopleByStoreId(id);
                RepoItem.DeleteItemByStoreId(id);
                RepoStore.DeleteStoreById(id);
                RepoStore.Save();

                return(RedirectToAction(nameof(Index)));
            }
            catch
            {
                return(View());
            }
        }
        public IActionResult Edit([FromRoute] int id, [Bind("LocationName")] StoreViewModel viewModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    Domain.Model.Store store = RepoStore.GetStoreById(id);
                    store.Name  = viewModel.LocationName;
                    store.Items = RepoItem.GetItemsByStoreName(viewModel.LocationName)
                                  .FindAll(p => p.StoreId == (RepoStore.GetStoresByName(viewModel.LocationName)
                                                              .First(p => p.Name == viewModel.LocationName).Id));
                    RepoStore.UpdateStore(store);
                    RepoStore.Save();

                    return(RedirectToAction(nameof(Index)));
                }
                return(View(viewModel));
            }
            catch (Exception)
            {
                return(View(viewModel));
            }
        }
Exemple #22
0
        public static RepoItem parse(string line)
        {
            //Debug.Log("Repo parse line " + line);
            RepoItem result = null;

            string[] parts = line.Split(Utils.itemSplitChar);

            if (parts.Length <= 4)
            {
                Type type = (Type)Enum.Parse(Type.SONG.GetType(), parts[0]);

                if (type == Type.PTRN)
                {
                    result = new RepoItem(parts[1], parts[2], parts[3], parts[4]);
                }
                else
                {
                    result = new RepoItem(type, parts[1], parts[2], parts[3]);
                }
            }

            return(result);
        }
        private Style GetItemStyle(RepoItem item)
        {
            Style style = CplusplusStyle;

            switch (item.language)
            {
            case "C++":
                style = CplusplusStyle;
                break;

            case "Java":
                style = JavaStyle;
                break;

            case "JavaScript":
                style = JavaScriptStyle;
                break;

            case "C":
                style = CStyle;
                break;

            case "C#":
                style = CsharpStyle;
                break;

            case "Ruby":
                style = RubyStyle;
                break;

            default:
                style = XSLTStyle;
                break;
            }
            return(style);
        }
Exemple #24
0
        public FrameworkElement RegisterControl(
            FrameworkElement fe, Func <object, LambdaAction> setValue, LambdaAction takeOverLambda = null)
        {
            // add item
            var it = new RepoItem();

            it.fwElem         = fe;
            it.setValueLambda = setValue;
            it.takeOverLambda = takeOverLambda;
            items.Add(fe, it);

            // put callbacks accordingly
            if (fe is TextBox)
            {
                var tb = fe as TextBox;
                it.originalValue = "" + tb.Text;
                tb.TextChanged  += Tb_TextChanged;
                tb.KeyUp        += Tb_KeyUp;
            }

            if (fe is Button btn)
            {
                btn.Click += B_Click;
            }

            if (fe is ComboBox cb)
            {
                it.originalValue = "" + cb.Text;
                cb.AddHandler(System.Windows.Controls.Primitives.TextBoxBase.TextChangedEvent,
                              new System.Windows.Controls.TextChangedEventHandler(Tb_TextChanged));
                if (!cb.IsEditable)
                {
                    // we need this event
                    cb.SelectionChanged += Cb_SelectionChanged;
                }
                if (cb.IsEditable)
                {
                    // add this for comfort
                    cb.KeyUp += Tb_KeyUp;
                }
            }

            if (fe is CheckBox ch)
            {
                it.originalValue = ch.IsChecked;
                ch.Checked      += Cb_Checked;
                ch.Unchecked    += Cb_Checked;
            }

            if (fe is MenuItem mi)
            {
                mi.Click += B_Click;
            }

            if (fe is Border brd && brd.Tag is string tag && tag == "DropBox")
            {
                brd.AllowDrop  = true;
                brd.DragEnter += (object sender2, DragEventArgs e2) =>
                {
                    e2.Effects = DragDropEffects.Copy;
                };
                brd.PreviewDragOver += (object sender3, DragEventArgs e3) =>
                {
                    e3.Handled = true;
                };
                brd.Drop += (object sender4, DragEventArgs e4) =>
                {
                    if (e4.Data.GetDataPresent(DataFormats.FileDrop, true))
                    {
                        // Note that you can have more than one file.
                        string[] files = (string[])e4.Data.GetData(DataFormats.FileDrop);

                        // Assuming you have one file that you care about, pass it off to whatever
                        // handling code you have defined.
                        if (files != null && files.Length > 0 &&
                            sender4 is FrameworkElement fe2 && items.ContainsKey(fe2))
                        {
                            var it2 = items[fe2];
                            if (it2.fwElem is Border brd2 && it2.setValueLambda != null)
                            {
                                // update UI
                                if (brd2.Child is TextBlock tb2)
                                {
                                    tb2.Text = "" + files[0];
                                }

                                // value changed
                                it2.setValueLambda(files[0]);

                                // contents changed
                                WishForOutsideAction.Add(new LambdaActionContentsChanged());
                            }
                        }
                    }

                    e4.Handled = true;
                };
            }

            return(fe);
        }
Exemple #25
0
        public void Post([FromUri] RepoItem value)
        {
            var x = Request.Content;

            HttpContext.Current.Session[value.Name] = true;
        }
Exemple #26
0
 public ItemViewModel(RepoItem repo)
 {
     this.Repo = repo;
 }
        protected override Style SelectStyleCore(object item, Windows.UI.Xaml.DependencyObject container)
        {
            RepoItem repo = (RepoItem)item;

            return(GetItemStyle(repo));
        }
 protected RepoItem(RepoItem other)
 {
     Id = other.Id;
 }
Exemple #29
0
    public RepoItem browserDetailSong(int index)
    {
        RepoItem songData = songList[songBrowserPageIndex * ITEMS_PER_PAGE + index];

        return(songData);
    }