Example #1
0
        public IHttpActionResult Post(ItemViewModels model)
        {
            string userId = User.Identity.GetUserId(); //brandon say something

            model.ItemsId = _adapter.AddItem(model, userId);
            return(Ok(model));
        }
Example #2
0
        public IActionResult GetBack(int itemId, bool isReturnSearch, string changeBeforeContent, bool isReturnHomePage)
        {
            var            items = _itemService.GetItem(itemId);
            ItemViewModels item  = _modelChange.ChangeItem(items);

            if (isReturnHomePage)
            {
                return(RedirectToAction("ShowHomePage", new { inventoryID = items.ItemOfInventoryId }));
            }
            if (isReturnSearch)
            {
                List <Items>          Viewitems = _itemService.SearchItem(changeBeforeContent, _userView.Id);
                List <ItemViewModels> _items    = _modelChange.ChangeItem(Viewitems);
                //items.Add(item);
                return(View("SearchReasult", _items));
            }
            if (item.State)
            {
                return(RedirectToAction("ShowAllFinishItem"));
            }
            if (item.IsOverdue)
            {
                return(RedirectToAction("ShowAllOverdueItem"));
            }
            return(RedirectToAction("ShowAllItem"));
        }
Example #3
0
        private void ConfigureForRemoval()
        {
            var itemsToRemove = new ObservableRangeCollection <BaseMenuItemViewModel> ();

            // Update each item in the list
            foreach (BaseMenuItemViewModel viewModel in ItemViewModels)
            {
                if (viewModel.MenuItemType == MenuItemType.Added)
                {
                    viewModel.MenuItemType = MenuItemType.Remove;
                }
                else
                {
                    itemsToRemove.Add(viewModel);
                }
            }

            // Remove the items that aren't editable
            if (itemsToRemove.Count > 0)
            {
                foreach (BaseMenuItemViewModel viewModel in itemsToRemove)
                {
                    ItemViewModels.Remove(viewModel);
                }
            }

            // Toggle the visibility of the "All accounts are removed" text
            ShowSubtitle = ItemViewModels.Count == 0;
        }
        public void Add(ItemViewModel itemViewModel)
        {
            TemplateItem templateItem = new TemplateItem(TemplateModel, itemViewModel.ItemModel);

            TemplateModel.TemplateItems.Add(templateItem);
            ItemViewModels.Add(ItemViewModelFactory.GetItemViewModel(templateItem));
        }
Example #5
0
        public void Add(ItemViewModel itemViewModel)
        {
            PanelItem panelItem = new PanelItem(PanelModel, itemViewModel.ItemModel);

            panelItem.Quantity = itemViewModel.Quantity;
            PanelModel.PanelItems.Add(panelItem);
            ItemViewModels.Add(ItemViewModelFactory.GetItemViewModel(panelItem));
        }
 public int DeleteItem(ItemViewModels item)
 {
     using (HappyPenguinDbContext db = new HappyPenguinDbContext())
     {
         var remove = db.Items.Where(x => x.ItemsId == item.ItemsId).SingleOrDefault();
         db.Items.Remove(remove);
         db.SaveChanges();
     }
     return(item.ItemsId);
 }
Example #7
0
        public IActionResult ChangeItem(int itemId, bool isReturnSearch, string content, bool isReturnHomePage)
        {
            ItemViewModels item = _modelChange.ChangeItem(_itemService.GetItem(itemId));

            if (item.TimeOfExpiration != null)
            {
                item.TimeToString = _modelChange.ChangeTimeToString((DateTime)item.TimeOfExpiration);
            }
            item.IsReturnSearch      = isReturnSearch;
            item.ChangeBeforeContent = content;
            item.IsReturnHomePage    = isReturnHomePage;
            return(View(item));
        }
Example #8
0
        private async Task <BaseMenuItemViewModel> TryAdd(BaseMenuItemViewModel viewModel)
        {
            var existingViewModel = ItemViewModels.FirstOrDefault(vm => ((BaseMenuItemViewModel)vm).Title.Equals(viewModel.Title)) as BaseMenuItemViewModel;

            if (existingViewModel == null)
            {
                existingViewModel = viewModel;

                await existingViewModel.DidLoad();

                ItemViewModels.Insert(0, existingViewModel);
            }
            return(existingViewModel);
        }
Example #9
0
        private void AddItem(int quantity)
        {
            bool isItemSame = false;

            ItemViewModel itemViewModel = new ItemViewModel();

            itemViewModel.Id          = 1;
            itemViewModel.CompanyId   = Convert.ToInt32(companyDropDownList.SelectedValue);
            itemViewModel.CompanyName = companyDropDownList.SelectedItem.ToString();
            itemViewModel.ItemId      = Convert.ToInt32(itemDropDownList.SelectedValue);
            itemViewModel.ItemName    = itemDropDownList.SelectedItem.ToString();
            itemViewModel.Quantity    = quantity;

            if (ViewState["itemVS"] == null)
            {
                ItemViewModels.Add(itemViewModel);
                ViewState["itemVS"] = ItemViewModels;

                stockOutGridView.DataSource = ItemViewModels;
                stockOutGridView.DataBind();
                outputLabel.Text = "Item Added";
            }
            else
            {
                ItemViewModels = (List <ItemViewModel>)ViewState["itemVS"];
                foreach (ItemViewModel itemView in ItemViewModels)
                {
                    if (itemView.CompanyId == itemViewModel.CompanyId && itemView.ItemId == itemViewModel.ItemId)
                    {
                        isItemSame = true;
                        break;
                    }
                }

                if (isItemSame)
                {
                    outputLabel.Text = "Item can not be same";
                }
                else
                {
                    itemViewModel.Id += ItemViewModels.Count;
                    ItemViewModels.Add(itemViewModel);
                    ViewState["itemVS"] = ItemViewModels;

                    stockOutGridView.DataSource = ItemViewModels;
                    stockOutGridView.DataBind();
                    outputLabel.Text = "Item Added";
                }
            }
        }
        private async Task DeleteItemsAsync()
        {
            LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() - Start ");

            var selectedItemViewModelsList = SelectedItemViewModels.ToList();

            var deletionCount = selectedItemViewModelsList.Count;

            if (deletionCount < 1)
            {
                return;
            }

            var dialogService       = Xamarin.Forms.DependencyService.Get <IDialogService>();
            var deleteStringContent = deletionCount > 1 ? $"{deletionCount}" : selectedItemViewModelsList.First().GetModelDisplayString(selectedItemViewModelsList.First().CurrentItem);
            var answer = await dialogService.ConfirmDeletion(deleteStringContent, deletionCount == 1);

            if (answer != true)
            {
                return;
            }

            await Task.Delay(100);

            lock (this.syncObj)
            {
                foreach (var viewModel in selectedItemViewModelsList)
                {
                    var state    = viewModel.InitialState;
                    var newState = ViewStatesHelper.MoveToState(viewModel.State, ViewStates.Deleting);
                    LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() - InitialState: {state}; newState: {newState}. ");
                    LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() -  Removing from selectedItemViewModels");

                    if (state != ViewStates.Creating && state != ViewStates.UpdatingCreate)
                    {
                        LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() - this is an existing item. continuing. ");
                        viewModel.IsSelected = false;
                        viewModel.State      = newState;
                        continue;
                    }

                    LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() - newly created item. can be easely discarded.. Removing from ItemViewModels. ");
                    ItemViewModels.Remove(viewModel);
                }

                LoggingService.Debug($"{LoggingPrefix}DeleteItemsAsync() - End ");
                this.RaisePropertyChanged(nameof(WrappedItemViewModels));
            }
        }
Example #11
0
        public ActionResult Create(ItemViewModels newItem, Guid?id)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new DataContext())
                {
                    Item itemToDatabase = new Item();
                    itemToDatabase.Name        = newItem.Name;
                    itemToDatabase.Description = newItem.Description;
                    itemToDatabase.CreateDate  = DateTime.Now.Date;
                    if (id.HasValue)
                    {
                        var target = ctx.UserFriends.Where(x => x.UserFriendID == id.Value).FirstOrDefault();
                        if (target.User1 == User.Identity.Name)
                        {
                            var findId = ctx.Users.Where(x => x.UserName == target.User2).FirstOrDefault();
                            itemToDatabase.OwnerId = findId.Id;
                        }
                        else
                        {
                            var findId = ctx.Users.Where(x => x.UserName == target.User1).FirstOrDefault();
                            itemToDatabase.OwnerId = findId.Id;
                        }
                    }
                    else
                    {
                        itemToDatabase.OwnerId = User.Identity.GetUserId();
                    }

                    itemToDatabase.AuthorID = User.Identity.GetUserId();

                    ctx.Items.Add(itemToDatabase);
                    ctx.SaveChanges();
                    if (!id.HasValue)
                    {
                        return(RedirectToAction("CurrentUserItems"));
                    }
                    else
                    {
                        return(RedirectToAction("FriendsList", "Friend"));
                    }
                }
            }
            return(View());
        }
Example #12
0
        private async void OnListItemSelected(IListItem item)
        {
            var viewModel = item as BaseMenuItemViewModel;

            if (MenuState == MenuState.Remove)
            {
                //	if we're in remove mode, this also means this item has to be removed from the list
                ItemViewModels.Remove(viewModel);
                ShowSubtitle = ItemViewModels.Count == 0;
            }
            else
            {
                // If we're not, then that must mean we just added one
                await viewModel.DidLoad();
            }
            var addedCount = ItemViewModels.Count(vm => ((BaseMenuItemViewModel)vm).MenuItemType == MenuItemType.Added || ((BaseMenuItemViewModel)vm).MenuItemType == MenuItemType.Remove);
            //Title =  (addedCount == 0) ? String.Empty : _homeViewModel.GetName();
        }
        public ActionResult Create(ItemViewModels newItem)
        {
            if (ModelState.IsValid)
            {
                using (var ctx = new DataContext())
                {
                    Item itemToDatabase = new Item();
                    itemToDatabase.Name        = newItem.Name;
                    itemToDatabase.Description = newItem.Description;
                    itemToDatabase.CreateDate  = DateTime.Now.Date;
                    itemToDatabase.OwnerId     = User.Identity.GetUserId();


                    ctx.Items.Add(itemToDatabase);
                    ctx.SaveChanges();
                }
            }
            return(View());
        }
Example #14
0
        //将获得的Items的值传给ItemViewModels
        public List <ItemViewModels> SaveInViewModels(List <Items> notFinishItems)
        {
            List <ItemViewModels> itemsView = new List <ItemViewModels>();

            foreach (var item in notFinishItems)
            {
                ItemViewModels itemView = new ItemViewModels()
                {
                    Content           = item.Content,
                    CreateTime        = item.CreateTime,
                    ItemId            = item.ItemId,
                    UserId            = item.UserId,
                    ItemOfInventoryId = item.ItemOfInventoryId,
                    TimeOfExpiration  = item.TimeOfExpiration,
                    Mark = item.Mark,
                };
                itemsView.Add(itemView);
            }
            return(itemsView);
        }
Example #15
0
        public int AddItem(ItemViewModels model, string userId)
        {
            int itemItemId;

            using (HappyPenguinDbContext db = new HappyPenguinDbContext())
            {
                Item item = new Item
                {
                    ItemName = model.ItemName,
                    ItemsId  = model.ItemsId,
                    Price    = model.Price,
                    Image    = model.Image
                };

                db.Items.Add(item);
                db.SaveChanges();

                itemItemId = item.ItemsId;
            }
            return(itemItemId);
        }
        private void GetItems()
        {
            foreach (Item item in Items)
            {
                Company  = ItemManager.GetCompanyById(item.CompanyId);
                Category = ItemManager.GetCategoryById(item.CategoryId);

                ItemViewModel itemViewModel = new ItemViewModel();
                itemViewModel.Id           = ItemViewModels.Count + 1;
                itemViewModel.ItemName     = item.Name;
                itemViewModel.CompanyName  = Company.Name;
                itemViewModel.CategoryName = Category.Name;
                itemViewModel.Quantity     = item.Quantity;
                itemViewModel.ReorderLevel = item.ReorderLevel;

                ItemViewModels.Add(itemViewModel);
            }

            itemsGridView.DataSource = ItemViewModels;
            itemsGridView.DataBind();
        }
Example #17
0
        public ActionResult Details(int?id)
        {
            ItemViewModels items = new ItemViewModels();

            if (!id.HasValue)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            using (var ctx = new DataContext())
            {
                var itemDetail = ctx.Items.Find(id.Value);
                items.Name        = itemDetail.Name;
                items.Description = itemDetail.Description;
                items.CreateDate  = itemDetail.CreateDate;
                if (itemDetail == null)
                {
                    return(HttpNotFound());
                }

                return(View(items));
            }
        }
Example #18
0
 public ActionResult Create(string id, ItemViewModels newItem)
 >> >> >> > master
Example #19
0
 public ActionResult Create(ItemViewModels newItem, Guid?id)
 == == == =
Example #20
0
 public void CalculateInfo()
 {
     Price      = ItemViewModels.Select(x => (x.Price) * (x.Quantity)).Sum();
     Time       = ItemViewModels.Select(x => (x.Time) * (x.Quantity)).Sum();
     TotalPrice = Price * Quantity;
 }
Example #21
0
 public void Remove(int index)
 {
     PanelModel.PanelItems.RemoveAt(index);
     ItemViewModels.RemoveAt(index);
 }
Example #22
0
 public IHttpActionResult Delete(ItemViewModels item)
 {
     item.ItemsId = _adapter.DeleteItem(item);
     return(Ok(item));
 }
 public void Remove(int index)
 {
     TemplateModel.TemplateItems.RemoveAt(index);
     ItemViewModels.RemoveAt(index);
 }