예제 #1
0
 public ActionResult Index(ItemListModel model, string message = "")
 {
     ViewBag.ErrorMessage = message;
     SessionHelper.Item   = null;
     model.SOBId          = SessionHelper.SOBId;
     return(View(model));
 }
예제 #2
0
        public async Task <IActionResult> Details(int?id)
        {
            if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault())
            {
                if (id == null)
                {
                    return(NotFound());
                }

                var item = await _context.Items
                           .FirstOrDefaultAsync(m => m.Id == id);

                var itemModel = new ItemListModel();
                itemModel.Id               = item.Id;
                itemModel.Name             = item.Name;
                itemModel.PriceTL          = item.PriceTL;
                itemModel.Purpose          = item.Purpose;
                itemModel.RecordCreateTime = DateTime.Now;
                itemModel.rlt_Supplier_Id  = item.rlt_Supplier_Id;
                itemModel.BuyingDate       = item.BuyingDate;
                itemModel.LastUserName     = _context.Allocations.Where(w => w.rlt_Item_Id == id).OrderByDescending(o => o.RecordCreateTime).Select(s => s.User.Name + " " + s.User.Surname).FirstOrDefault() ?? null;
                if (item.ReturnDate != null)
                {
                    itemModel.ReturnDate = (DateTime)item.ReturnDate;
                }
                if (item == null)
                {
                    return(NotFound());
                }

                return(View(itemModel));
            }
            return(RedirectToAction("Logout", "Login"));
        }
예제 #3
0
        public ActionResult ItemList(DataSourceRequest command, ItemListModel model)
        {
            var categoryIds = new List <int> {
                model.SearchCategoryId
            };

            var items = _itemService.SearchItems(
                categoryIds: categoryIds,
                itemType: model.SearchItemTypeId > 0 ? (ItemType?)model.SearchItemTypeId : null,
                keywords: model.SearchItemName,
                pageIndex: command.Page - 1,
                pageSize: command.PageSize
                );

            var gridModel = new DataSourceResult();

            gridModel.Data = items.Select(x =>
            {
                var itemModel             = x.ToModel();
                itemModel.FullDescription = "";

                itemModel.FullDescription     = "";
                var defaultItemPicture        = _pictureService.GetPicturesByItemId(x.Id, 1).FirstOrDefault();
                itemModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultItemPicture, 75, true);

                itemModel.ItemTypeName = x.ItemType.ToString();

                return(itemModel);
            });
            gridModel.Total = items.TotalCount;

            return(Json(gridModel));
        }
예제 #4
0
        public ActionResult ItemBidList(DataSourceRequest command, ItemListModel model)
        {
            var items = _workContext.CurrentUser.Bids.Select(b => b.Item).DistinctBy(i => i.Id);

            var gridModel = new DataSourceResult();

            var enumerable = items as IList <Item> ?? items.ToList();

            gridModel.Data = enumerable.Select(x =>
            {
                var itemModel             = x.ToModel();
                itemModel.FullDescription = "";

                itemModel.FullDescription     = "";
                var defaultItemPicture        = _pictureService.GetPicturesByItemId(x.Id, 1).FirstOrDefault();
                itemModel.PictureThumbnailUrl = _pictureService.GetPictureUrl(defaultItemPicture, 75, true);

                itemModel.ItemTypeName = x.ItemType.ToString();

                return(itemModel);
            });
            gridModel.Total = enumerable.Count();

            return(Json(gridModel));
        }
예제 #5
0
 public ItemsListView(Object Parameter)
 {
     InitializeComponent();
     InitializeComponent();
     parameter      = Parameter;
     BindingContext = new ItemListModel();
 }
예제 #6
0
        public ActionResult MyItems()
        {
            if (!_workContext.CurrentUser.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new ItemListModel();

            // категории
            model.AvailableCategories.Add(new SelectListItem {
                Text = "Все", Value = "0"
            });
            var categories = SelectListHelper.GetCategoryList(_categoryService, true);

            foreach (var c in categories)
            {
                model.AvailableCategories.Add(c);
            }

            // типы товаров
            model.AvailableItemTypes = ItemType.ShopItem.ToSelectList(false).ToList();
            model.AvailableItemTypes.Insert(0, new SelectListItem {
                Text = "Все", Value = "0"
            });

            return(View(model));
        }
예제 #7
0
        public IActionResult AddItem(ItemListModel item)
        {
            if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault())
            {
                if (ModelState.IsValid)
                {
                    using (EntityDbContext entity = _context)
                    {
                        var itemModel = new Item();
                        itemModel.Id               = item.Id;
                        itemModel.Name             = item.Name;
                        itemModel.PriceTL          = item.PriceTL;
                        itemModel.Purpose          = item.Purpose;
                        itemModel.RecordCreateTime = DateTime.Now;

                        if (item.rlt_Supplier_Id == 0)
                        {
                            var supplier = new Supplier();
                            supplier.RecordCreateTime = DateTime.Now;
                            supplier.Name             = item.Supplier.Name;
                            supplier.Phone            = item.Supplier.Phone;
                            supplier.Email            = item.Supplier.Email;
                            _context.Suppliers.Add(supplier);
                            _context.SaveChanges();
                            itemModel.rlt_Supplier_Id = supplier.Id;
                        }
                        else
                        {
                            itemModel.rlt_Supplier_Id = item.rlt_Supplier_Id;
                        }
                        itemModel.BuyingDate = item.BuyingDate;
                        _context.Items.Add(itemModel);
                        _context.SaveChanges();

                        int id = itemModel.Id;

                        if (item.rlt_User_Id != 0)
                        {
                            var allocation = new Allocation();
                            allocation.ItemGivenTime    = DateTime.Now;
                            allocation.RecordCreateTime = DateTime.Now;
                            allocation.rlt_Item_Id      = id;
                            allocation.rlt_User_Id      = item.rlt_User_Id;
                            _context.Allocations.Add(allocation);
                            _context.SaveChanges();
                        }
                    }



                    return(RedirectToAction(nameof(ItemList)));
                }

                ViewData["rlt_User_Id"]     = new SelectList(_context.Users, "Id", "Name");
                ViewData["rlt_Supplier_Id"] = new SelectList(_context.Suppliers, "Id", "Name");
                return(View());
            }
            return(RedirectToAction("Logout", "Login"));
        }
        public async Task Should_Return_Projects_Count_According_To_Filter_Parameters(
            ProjectSearchParametersModel parameters, Int32 expectedCount)
        {
            using (WavesDbContext context = new WavesDbContext(_fixture.DbOptions))
            {
                IProjectStore store = _GetProjectStore(context);
                ItemListModel <ProjectDTO> result = await store.GetAsync(parameters);

                Assert.Equal(expectedCount, result.TotalCount);
            }
        }
예제 #9
0
        public ActionResult MyBids()
        {
            if (!_workContext.CurrentUser.IsRegistered())
            {
                return(new HttpUnauthorizedResult());
            }

            var model = new ItemListModel();

            return(View(model));
        }
예제 #10
0
        public ActionResult Items()
        {
            ItemListModel i = null;

            using (var client = new WebClient())
            {
                var json = client.DownloadString("http://ddragon.leagueoflegends.com/cdn/7.22.1/data/en_US/item.json");
                i = JsonConvert.DeserializeObject <ItemListModel>(json);
            }
            return(View(i));
        }
예제 #11
0
        public ItemList(ItemListModel model) : base(model)
        {
            this.Title          = "My tasks";
            this.BindingContext = model;

            var itemList = new ListView
            {
                HasUnevenRows          = true,
                IsPullToRefreshEnabled = false,
                SelectionMode          = ListViewSelectionMode.None,
                RowHeight           = AppStyles.ListRowHeight,
                SeparatorVisibility = SeparatorVisibility.Default,
                ItemTemplate        = new DataTemplate(typeof(ItemListCell)),
                VerticalOptions     = LayoutOptions.StartAndExpand,
                HorizontalOptions   = LayoutOptions.Fill,
                BackgroundColor     = Color.Transparent
            };

            itemList.SetBinding <ItemListModel>(ListView.ItemsSourceProperty, m => m.Items);
            itemList.SetBinding <ItemListModel>(ListView.IsRefreshingProperty, m => m.IsDataLoading);
            itemList.SetBinding <ItemListModel>(ListView.RefreshCommandProperty, m => m.RefreshCommand);
            itemList.SetBinding <ItemListModel>(ListView.HeightRequestProperty, m => m.ListHeightRequest);
            itemList.ItemTapped += ItemTapped;

            var emptyState = new Label()
            {
                Text = "You've got nothing to do! Add a task 👆",
                HorizontalOptions = LayoutOptions.Center,
                VerticalOptions   = LayoutOptions.Start,
                Padding           = new Thickness(0, 20, 0, 0)
            };

            emptyState.SetBinding <ItemListModel>(Label.IsVisibleProperty, m => m.ListIsEmpty);

            this.Content = new StackLayout()
            {
                Orientation       = StackOrientation.Vertical,
                HorizontalOptions = LayoutOptions.Fill,
                VerticalOptions   = LayoutOptions.Fill,
                Children          = { emptyState, itemList }
            };

            ToolbarItems.Add(new ToolbarItem("Add", null, () =>
            {
                NavigationPage.SetBackButtonTitle(this, "Cancel");
                Navigation.PushAsync(new ItemDetails(new ItemModel(new TodoItem(0, "", "", DateTime.Now, State.Open))));
            }));
        }
예제 #12
0
        public IActionResult Edit(int?id)
        {
            if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault())
            {
                if (id == null)
                {
                    return(NotFound());
                }
                var item = _context.Items.Find(id);
                if (item == null)
                {
                    return(NotFound());
                }
                ItemListModel sendmodel   = new ItemListModel();
                var           rlt_User_Id = _context.Allocations.Where(q => q.rlt_Item_Id == id).OrderByDescending(i => i.ItemGivenTime).Select(q => q.rlt_User_Id).FirstOrDefault();

                sendmodel.Id              = item.Id;
                sendmodel.Name            = item.Name;
                sendmodel.PriceTL         = item.PriceTL;
                sendmodel.Purpose         = item.Purpose;
                sendmodel.BuyingDate      = item.BuyingDate;
                sendmodel.rlt_Supplier_Id = item.rlt_Supplier_Id;
                sendmodel.rlt_User_Id     = rlt_User_Id;


                sendmodel.LastUserName = _context.Allocations.Where(w => w.rlt_Item_Id == id).OrderByDescending(o => o.RecordCreateTime).Select(s => s.User.Name + " " + s.User.Surname).FirstOrDefault() ?? null;
                if (sendmodel.LastUserName != null)
                {
                    sendmodel.ReturnDate = DateTime.Now;
                }
                sendmodel.LastUserId = _context.Allocations.Where(w => w.rlt_Item_Id == id).OrderByDescending(o => o.RecordCreateTime).Select(s => s.User.Id).FirstOrDefault();

                var userselect = _context.Users.Select(x =>
                                                       new
                {
                    Id   = x.Id,
                    Name = x.Name + " " + x.Surname
                });

                ViewData["rlt_Supplier_Id"] = new SelectList(_context.Suppliers, "Id", "Name", item.rlt_Supplier_Id);
                ViewData["rlt_User_Id"]     = new SelectList(userselect, "Id", "Name", sendmodel.rlt_User_Id).Append(new SelectListItem("Daha önce kimseye tahsis edilmedi.", "0"));
                return(View(sendmodel));
            }
            return(RedirectToAction("Logout", "Login"));
        }
예제 #13
0
        public ItemListModel Create(IQueryable <Item> items, bool orderActivated = false)
        {
            var model = new ItemListModel();

            model.Items          = new List <ItemModel>();
            model.OrderActivated = orderActivated;

            foreach (var item in items)
            {
                model.Items.Add(new ItemModel
                {
                    Id       = item.Id,
                    ImageUrl = item.ImageUrl,
                    Name     = item.Name,
                    Price    = item.Price
                });
            }
            return(model);
        }
예제 #14
0
        public async Task <int> AddItem(ItemListViewModel model)
        {
            var alreadyExist = await dbContext.ItemList.Where(x => x.Name == model.Name).FirstOrDefaultAsync();

            if (alreadyExist != null)
            {
                return(-1);
            }
            else
            {
                ItemListModel temp = new ItemListModel()
                {
                    Name     = model.Name,
                    Category = model.Category,
                };
                dbContext.ItemList.Add(temp);
                var row = dbContext.SaveChanges();
                return(row);
            }
        }
예제 #15
0
        public IActionResult AddItemList(int userGroupId, [FromBody] ItemListModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var itemList = _mapper.Map <ItemList>(model);

            try
            {
                var group = _userGroupService.GetById(userGroupId);

                _itemListService.Create(itemList);
                group.ItemList = itemList;

                return(Ok(group));
            }
            catch (AppException ex)
            {
                return(BadRequest(new { message = ex }));
            }
        }
예제 #16
0
        public IActionResult Create([FromBody] ItemListModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // map model to entity
            var itemList = _mapper.Map <ItemList>(model);


            try
            {
                // create item
                _itemListService.Create(itemList);
                return(Ok(itemList));
            }
            catch (AppException ex)
            {
                // return error message if there was an exception
                return(BadRequest(new { message = ex.Message }));
            }
        }
예제 #17
0
        public async Task <IActionResult> Edit(int id, ItemListModel itemmodel)
        {
            if (User.Claims.Select(q => q.Value).FirstOrDefault() != null && HttpContext.Session.GetString("UserLoginEmail") == User.Claims.Select(q => q.Value).FirstOrDefault())
            {
                Item item = new Item();
                item.Id              = itemmodel.Id;
                item.Name            = itemmodel.Name;
                item.PriceTL         = itemmodel.PriceTL;
                item.Purpose         = itemmodel.Purpose;
                item.BuyingDate      = itemmodel.BuyingDate;
                item.rlt_Supplier_Id = itemmodel.rlt_Supplier_Id;
                if (itemmodel.ReturnDate != null)
                {
                    item.ReturnDate = itemmodel.ReturnDate;
                }

                item.RecordCreateTime = DateTime.Now;
                if (id != item.Id)
                {
                    return(NotFound());
                }

                if (ModelState.IsValid)
                {
                    try
                    {
                        _context.Items.Update(item);
                        await _context.SaveChangesAsync();

                        if (itemmodel.rlt_User_Id != 0)
                        {
                            var allocation = new Allocation();

                            allocation.ItemGivenTime    = DateTime.Now;
                            allocation.RecordCreateTime = DateTime.Now;
                            allocation.rlt_Item_Id      = id;
                            allocation.rlt_User_Id      = itemmodel.rlt_User_Id;
                            _context.Allocations.Add(allocation);
                            _context.SaveChanges();
                        }
                    }
                    catch (DbUpdateConcurrencyException)
                    {
                        if (!ItemExists(item.Id))
                        {
                            return(NotFound());
                        }
                        else
                        {
                            throw;
                        }
                    }
                    return(RedirectToAction(nameof(ItemList)));
                }


                ViewData["rlt_Supplier_Id"] = new SelectList(_context.Suppliers, "Id", "Id", item.rlt_Supplier_Id);
                return(View(item));
            }
            return(RedirectToAction("Logout", "Login"));
        }
예제 #18
0
 public ActionResult ItemPartial(ItemListModel model)
 {
     return(PartialView("_List", ItemHelper.GetItems(SessionHelper.SOBId)));
 }
예제 #19
0
        /// <summary>
        /// Item private (from Get、Preview)
        /// </summary>
        /// <param name="oriData"></param>
        /// <param name="viewName">回傳view</param>
        /// <param name="itemType">指定類型</param>
        /// <returns></returns>
        public CiResult <object> ShowItem(ItemViewModel oriData, ref string viewName, ItemType?itemType = null)
        {
            var result = new CiResult <object>();
            var data   = TransModel(oriData);

            if (data == null) // || string.IsNullOrEmpty(structure.ViewName)
            {
                result.Message = "data not found";
                return(result); //404
            }

            #region 取得資料

            //結構
            var structure = structureService.Get(data.Item.StructureID);
            if (structure == null) // || string.IsNullOrEmpty(structure.ViewName)
            {
                result.Message = "structure not found";
                return(result); //404
            }

            //子結構(子分類) 文章後推一層
            var subStructures = structureService.GetByParent(structure.ID.ToListObject(), ItemType.CategorySub);
            var subItemList   = new PageModel <ItemViewModel>();
            if (subStructures.Any())
            {
                subItemList = service.GetListView(
                    new PageParameter
                {
                    SortColumn = SortColumn.Sort,
                    IsPaged    = false
                }, new ItemFilter
                {
                    LangType     = ApplicationHelper.DefaultLanguage,
                    StructureIDs = subStructures.Select(x => x.ID).ToList(),
                    CategoryIDs  = data.Item.ID.ToListObject()
                });
            }

            /****若有子分類,文章往後推一層****/

            //子結構(多種文章)
            List <Guid> articleStructureID = (subStructures.Any()) ? subStructures.Select(x => x.ID).ToList() : structure.ID.ToListObject();
            var         articleStructures  = structureService.GetByParent(articleStructureID, ItemType.Article);
            //分頁參數
            var pageModel = new ItemPageModel();
            if (articleStructures != null)
            {
                //所有層級Category都可 (父層分類可找到子層分類的文章)
                var CategoryIDs = data.Item.ID.ToListObject();
                if (subStructures.Any())
                {
                    CategoryIDs.AddRange(subItemList.Data.Select(x => x.Item.ID).ToList());
                }
                pageModel.CategoryJson  = _Json.ModelToJson(CategoryIDs);
                pageModel.StructureJson = _Json.ModelToJson(articleStructures.Select(x => x.ID));
                //sort
                if (articleStructures.All(x => x.RequiredTypes.HasValue((int)ContentType.Date)))
                {
                    pageModel.SortColumn = SortColumn.Date;
                }
                else if (articleStructures.All(x => x.RequiredTypes.HasValue((int)ContentType.Sort)))
                {
                    pageModel.SortColumn = SortColumn.Sort;
                }
                else
                {
                    pageModel.SortColumn = SortColumn.CreateTime;
                }

                //人才庫
                if (articleStructures.Any(x => x.ItemTypes.HasValue((int)ItemType.Q8People)))
                {
                    pageModel.DataLevel = DataLevel.Normal;
                }
            }

            #endregion

            #region 回傳頁面
            //// ckeditor
            //data.ItemLanguage.Content = HttpUtility.HtmlDecode(data.ItemLanguage.Content);
            //data.ItemLanguage.TemplateText = HttpUtility.HtmlDecode(data.ItemLanguage.TemplateText);

            //Banner
            //if (structure.ItemTypes.HasValue((int)ItemType.Banner) || itemType == ItemType.Banner)
            //{
            //    if (articleStructure == null)
            //        return null; //404

            //    pageModel.ViewName = structure.ViewName;
            //    pageModel.IsPaged = false;

            //    return pageModel;

            //}

            // else

            //內容 Detail
            if (structure.ItemTypes.HasValue((int)ItemType.Article) || itemType == ItemType.Article)
            {
                viewName         = structure.ViewName;
                result.Data      = data;
                result.IsSuccess = true;
                return(result);
            }
            //列表 List
            else if (structure.ItemTypes.HasValue((int)ItemType.Category) || itemType == ItemType.Category)
            {
                //子結構可以是文章或次分類
                if (!articleStructures.Any() && !subStructures.Any())
                {
                    return(result); //404
                }
                pageModel.ViewName = structure.ViewName + "_Page";
                var model = new ItemListModel
                {
                    ItemViewModel = data,
                    ItemPageModel = pageModel,
                };
                if (subItemList.Data != null)
                {
                    model.SubItemList = new List <ItemWebViewModel>(
                        subItemList.Data?.Select(x => TransModel(x)).ToList()
                        );
                }

                viewName         = structure.ViewName;
                result.Data      = model;
                result.IsSuccess = true;
                return(result);
            }

            result.Message = "type not found";
            return(result); //404

            #endregion
        }