예제 #1
0
        public Boolean DeleteMenu(Int32 id) {
            ItemService _itemService = new ItemService();
            InventoryService _inventoryService = new InventoryService();

            try {
                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    ChecksMenu menuItem = db.ChecksMenus.FirstOrDefault(m => m.id == id);
                    if (menuItem != default(ChecksMenu)) {
                        db.ChecksMenus.DeleteOnSubmit(menuItem);
                        IEnumerable<ChecksMenuProduct> products = db.ChecksMenuProducts.Where(m => m.CheckMenuId == id);
                        if (products.Any()) {
                            db.ChecksMenuProducts.DeleteAllOnSubmit(products);
                            foreach (ChecksMenuProduct product in products) {
                                IEnumerable<ChecksMenuProductItem> items = db.ChecksMenuProductItems.Where(m => m.ProductId == product.id);
                                db.ChecksMenuProductItems.DeleteAllOnSubmit(items);
                            }
                        }
                    }
                    db.SubmitChanges();
                }
            }
            catch (Exception ex) {
                return false;
            }
            return true;
        }
        /// <summary>
        /// Constructs the Freshbooks API authentication and wrapper class
        /// </summary>
        /// <param name="accountName">The account name for which you are trying to access</param>
        /// <param name="consumerKey">The developer's freshbooks account name</param>
        /// <param name="oauthSecret">The developer's oauth-secret provided by freshbooks</param>
        public FreshbooksApi(string accountName, string consumerKey, string oauthSecret)
        {
            _accountName = accountName;
            _consumerKey = consumerKey;
            _oauthSecret = oauthSecret ?? String.Empty;

            _baseUri = new UriBuilder { Scheme = "https", Host = accountName + ".freshbooks.com" }.Uri;
            _serviceUri = new Uri(_baseUri, "/api/2.1/xml-in");
            Clear();

            UserAgent = String.Format("{0}/{1} ({2})", 
                GetType().Name,
                GetType().Assembly.GetName().Version.ToString(2), 
                GetType().Assembly.FullName);

            Callback = new CallbackService(new ServiceProxy(this, "callback"));
            Category = new CategoryService(new ServiceProxy(this, "category"));
            Client = new ClientService(new ServiceProxy(this, "client"));
            Estimate = new EstimateService(new ServiceProxy(this, "estimate"));
            Expense = new ExpenseService(new ServiceProxy(this, "expense"));
            Gateway = new GatewayService(new ServiceProxy(this, "gateway"));
            Invoice = new InvoiceService(new ServiceProxy(this, "invoice"));
            Item = new ItemService(new ServiceProxy(this, "item"));
            Language = new LanguageService(new ServiceProxy(this, "language"));
            Payment = new PaymentService(new ServiceProxy(this, "payment"));
            Project = new ProjectService(new ServiceProxy(this, "project"));
            Recurring = new RecurringService(new ServiceProxy(this, "recurring"));
            System = new SystemService(new ServiceProxy(this, "system"));
            Staff = new StaffService(new ServiceProxy(this, "staff"));
            Task = new TaskService(new ServiceProxy(this, "task"));
            Tax = new TaxService(new ServiceProxy(this, "tax"));
            TimeEntry = new TimeEntryService(new ServiceProxy(this, "time_entry"));
        }
        public void GetIdIfItemDontFindedReturns0()
        {
            IItemService itemService = new ItemService();

            var newItem = GetNewItem();

            var id = itemService.GetId(newItem);

            Assert.Equal(0, id);
        }
예제 #4
0
        /// <summary>
        /// Rebind control 
        /// </summary>
        protected void PageChanged(object sender, DataGridPageChangedEventArgs e)
        {
            //reset index
            itemsGrid.CurrentPageIndex = e.NewPageIndex;

            //get category id
            string productId = Request.QueryString["productId"];

            var itemService = new ItemService();
            itemsGrid.DataSource = itemService.GetByProductId(productId);
            itemsGrid.DataBind();
        }
        public void GetIdMethodMustExtractDataFromDataContext()
        {
            var dataContext = new Mock<IDataContext>();
            dataContext.Setup(x => x.GetTable<Item>())
                .Returns(ActualDataContext.Items);
            IItemService userService = new ItemService(dataContext.Object);

            var newItem = GetNewItem();

            userService.GetId(newItem);

            dataContext.Verify(dc => dc.GetTable<Item>(),
                Times.Once());
        }
예제 #6
0
        public ActionResult Index(string search)
        {
            SearchItemViewModel searchItemViewModel = new SearchItemViewModel();
            ItemService iss = new ItemService();
            var queueItems = new QueueService().GetQueue(MediaSwap.Web.Models.MediaSwapIdentity.Current.Id);

            searchItemViewModel.ItemResults = iss.Search(search).Select(s=>new SearchItemViewModel.ItemResult(){ Item  = s}).ToList();
            foreach (var queueItem in queueItems)
            {
               var searchItem =  searchItemViewModel.ItemResults.FirstOrDefault(i => i.Item.ItemId == queueItem.ItemId);
               if (searchItem != null)
               {
                   searchItem.Status = queueItem.Status;
               }
            }
            return View(searchItemViewModel);
        }
예제 #7
0
        public List <string> GetItemRef(string UserName)
        {
            var ImageStorerepo = new ImageStoreService();
            var Itemrepo       = new ItemService();
            List <ItemModelview> lstItemModelview = new List <ItemModelview>();
            var lstimgId = ImageStorerepo.GetAll().FindAll(x => x.UserName.Equals(UserName)).Select(w => w.imgId);

            List <string> lstItemref = new List <string>();

            foreach (var item in lstimgId)
            {
                string x = item.Substring(0, item.Length - 1);
                if (!lstItemref.Contains(x))
                {
                    lstItemref.Add(x);
                }
            }
            return(lstItemref);
        }
예제 #8
0
        public BetModelView GetBet(string id)
        {
            var Itemrepo = new ItemService();

            using (var Betrepo = new BetService())
            {
                var model        = Betrepo.GetById(id);
                var betModelView = new BetModelView
                {
                    itemref      = model.ItemRef,
                    Currentprice = Itemrepo.GetById(model.ItemRef).ItemPrice,
                    Newprice     = model.NewPrice,
                    IsAccept     = model.IsAccept,
                    date         = model.date,
                    BetterName   = model.BetterName
                };
                return(betModelView);
            }
        }
예제 #9
0
        public List <BetModelView> GetAllNotUpdateBet()
        {
            var Itemrepo = new ItemService();

            using (var Betrepo = new BetService())
            {
                return(Betrepo.GetAll().Where(x => x.IsAccept == 0).Select(model => new BetModelView()
                {
                    itemref = model.ItemRef,
                    Currentprice = Itemrepo.GetById(model.ItemRef.Substring(model.ItemRef.IndexOf('-') + 1)).ItemPrice,
                    Newprice = model.NewPrice,
                    IsAccept = model.IsAccept,
                    date = model.date,
                    BetterName = model.BetterName,
                    ItemName = Itemrepo.GetById(model.ItemRef.Substring(model.ItemRef.IndexOf('-') + 1)).ItemName,
                    ItemDescription = Itemrepo.GetById(model.ItemRef.Substring(model.ItemRef.IndexOf('-') + 1)).ItemDescription
                }).ToList());
            }
        }
예제 #10
0
        public List <BetModelView> GetUpdatedBet(string username)
        {
            var Itemrepo = new ItemService();

            using (var Betrepo = new BetService())
            {
                return(Betrepo.GetAll().Where(x => x.IsAccept != 0 && x.BetterName == username && x.IsRead == false).Select(model => new BetModelView()
                {
                    itemref = model.ItemRef,
                    Newprice = model.NewPrice,
                    IsAccept = model.IsAccept,
                    date = model.date,
                    BetterName = model.BetterName,
                    ItemName = Itemrepo.GetById(model.ItemRef.Substring(model.ItemRef.IndexOf('-') + 1)).ItemName,
                    ItemDescription = Itemrepo.GetById(model.ItemRef.Substring(model.ItemRef.IndexOf('-') + 1)).ItemDescription,
                    Message = GetMessage(model.IsAccept)
                }).ToList());
            }
        }
예제 #11
0
        public void UpdateTest()
        {
            var repo = new Mock <IItemRepository>();
            var item = new Item()
            {
                Title = "Edu"
            };

            repo.Setup(x => x.GetById(It.IsAny <int>())).Returns(item);
            repo.Setup(x => x.Update(It.IsAny <Item>()));

            var service = new ItemService(repo.Object);
            var res     = service.Update(new Item()
            {
                Title = "Name2"
            });

            Assert.IsTrue(res.ExecutedSuccesfully);
        }
예제 #12
0
        public void ValidateOnCreateTest_WhenTitleItsNotUnique()
        {
            var repo = new Mock <IItemRepository>();
            var item = new Item()
            {
                Title = "Edu"
            };

            repo.Setup(x => x.GetByFilter(
                           It.IsAny <int>(), It.IsAny <int>(), It.IsAny <Func <Item, bool> >()))
            .Returns(new List <Item> {
                item
            });

            var service = new ItemService(repo.Object);
            var res     = service.ValidateOnCreate(item);

            Assert.IsFalse(res.ExecutedSuccesfully);
        }
예제 #13
0
        private void SetLoad()
        {
            Roll_Service service = new Roll_Service();

            dataGridView1.DataSource = service.getRollWork();

            WorkOrderService service2 = new WorkOrderService();

            processWorkList = service2.GetPrcocess_Workorder(main.lbl_Job.Text);
            ItemService service3 = new ItemService();

            itemList = service3.GetAllItemInfo();
            WorkCenterService wcService = new WorkCenterService();

            wcPortList = wcService.WorkCenterPortNum();

            // MoldStart_Service service6 = new MoldStart_Service();
            //DataGridViewComboBoxCell = service6.GetMoldName(work);
        }
예제 #14
0
        public void Main()
        {
            var         disturbType = _.GetInventoryDisturbType();
            NWItem      item        = (_.GetInventoryDisturbItem());
            NWCreature  creature    = (_.GetLastDisturbed());
            NWPlaceable container   = (_.OBJECT_SELF);

            if (disturbType == DisturbType.Added)
            {
                ItemService.ReturnItem(creature, item);
            }
            else if (disturbType == DisturbType.Removed)
            {
                if (!container.InventoryItems.Any())
                {
                    container.Destroy();
                }
            }
        }
예제 #15
0
        public void SuccessfulCreate()
        {
            var input  = new DomainItemUpdateModel();
            var output = new DomainItem();

            var serviceMockup = new Mock <IPlayerValidate>();

            serviceMockup.Setup(x => x.ValidatePlayer(input));

            var repositoryMockup = new Mock <IItemRepository>();

            repositoryMockup.Setup(x => x.Add(input)).Returns(output);

            var service = new ItemService(repositoryMockup.Object, serviceMockup.Object);

            var result = service.CreateEntity(input);

            result.Should().Be(output);
        }
        public ActionResult Edit(int?id)
        {
            if (null == id)
            {
                return(HttpNotFound());
            }

            itemService = new ItemService();
            var chk = itemService.Query((int)id);

            if (null == chk)
            {
                return(HttpNotFound());
            }
            else
            {
                return(View(chk));
            }
        }
예제 #17
0
        /// <summary>
        ///  通过传iid来绑定商品属性到面板
        /// </summary>
        /// <param name="iid"></param>
        /// <param name="sku_props_name"></param>
        private void ShowItemPropValue(string iid, string sku_props_name)
        {
            Alading.Entity.Item vsItem = ItemService.GetItem(iid);
            if (vsItem == null) //如果为空 则不绑定
            {
                return;
            }
            ShopItem sItem = new ShopItem();

            sItem.cid            = vsItem.cid;
            sItem.input_pids     = vsItem.input_pids;
            sItem.input_str      = vsItem.input_str;
            sItem.property_alias = vsItem.property_alias;
            sItem.props          = vsItem.props;
            sItem.SkuProps       = string.Empty;
            sItem.SkuProps_Str   = sku_props_name;

            UIHelper.ShowItemPropValue(sItem, categoryRowKeyProps, categoryRowSaleProps, categoryRowNotKeyProps, categoryRowStockProps);
        }
        public async Task ThrowArgumentNullException_WhenPassedNullFilter()
        {
            // Arrange
            Mock <IPandaScoreClient> pandaScoreClientMock = new Mock <IPandaScoreClient>();
            Mock <DataContext>       dataContextMock      = new Mock <DataContext>();

            string validSortOrder  = string.Empty;
            string invalidFilter   = null;
            int    validPageNumber = 1;
            int    validPageSize   = 10;

            ItemService SUT = new ItemService(
                pandaScoreClientMock.Object,
                dataContextMock.Object);

            // Act & Assert
            await Assert.ThrowsExceptionAsync <ArgumentNullException>(
                () => SUT.FilterItemsAsync(validSortOrder, invalidFilter, validPageNumber, validPageSize));
        }
예제 #19
0
        static void Main(string[] args)
        {
            //Initialize required services
            var printService        = new ConsolePrinter();
            var itemService         = new ItemService();
            var dayService          = new DayService(printService);
            var agedBrieService     = new AgedBrieService(itemService);
            var backstageService    = new BackstageService(itemService);
            var normalItemService   = new NormalItemService(itemService);
            var conjuredItemService = new ConjuredItemService(itemService);
            //Get all items
            var items = itemService.CreateItems();
            //Create app with all business logic
            var app = new GildedRoseClass(items, agedBrieService, backstageService, normalItemService, conjuredItemService);
            //Print all 30 days results
            var thirtyDaysService = new ThirtyDaysService(printService, dayService, app);

            thirtyDaysService.PrintThirtyDaysItemsResults(items);
        }
        public ActionResult Delete(int?id)
        {
            if (null == id)
            {
                return(HttpNotFound());
            }

            itemService = new ItemService();
            var chk = itemService.Remove((int)id);

            if (chk)
            {
                return(RedirectToAction("Index"));
            }
            else
            {
                return(HttpNotFound());
            }
        }
예제 #21
0
        public void GetItemByNameTest_Found()
        {
            var repo = new Mock <IItemRepository>();
            var item = new Item()
            {
                Title = "Edu"
            };

            repo.Setup(x => x.GetByFilter(
                           It.IsAny <int>(), It.IsAny <int>(), It.IsAny <Func <Item, bool> >()))
            .Returns(new List <Item> {
                item
            });

            var service = new ItemService(repo.Object);
            var res     = service.GetItemByName("Edu");

            Assert.AreEqual(res, item);
        }
예제 #22
0
        public ActionResult Edit(int ItemId)
        {
            CategoryService    objCatServ  = new CategoryService();
            CategoryItem       objCatItem  = new CategoryItem();
            ItemService        objItemServ = new ItemService();
            AssestsItem        objItem     = new AssestsItem();
            List <AssestsItem> lstItems    = new List <AssestsItem>();

            objItem = objItemServ.GetItemsById(ItemId);
            int cid = 0;

            if (Session["CompID"] != null)
            {
                cid = Convert.ToInt32(Session["CompID"].ToString());
            }
            lstItems           = objItemServ.GetALLItems(cid);
            objItem.lstOfItems = new List <AssestsItem>();
            objItem.lstOfItems.AddRange(lstItems);

            List <CategoryItem> lstCat = new List <CategoryItem>();

            lstCat = objCatServ.GetALL(cid);
            objItem.lstCategory = new List <CategoryItem>();
            objItem.lstCategory.AddRange(lstCat);

            SponsorService     objService = new SponsorService();
            List <CompanyItem> lstCompany = new List <CompanyItem>();

            lstCompany          = objService.GetCompany();
            objItem.ListCompany = new List <CompanyItem>();
            objItem.ListCompany.AddRange(lstCompany);

            VehicleMasterService objVehicle = new VehicleMasterService();

            #region Bind DropDown Branch
            List <BranchItem> lstBranch = new List <BranchItem>();
            lstBranch          = objVehicle.GetBranch();
            objItem.ListBranch = new List <BranchItem>();
            objItem.ListBranch.AddRange(lstBranch);
            #endregion

            return(View(objItem));
        }
        /// <summary>
        /// Load all items with a location attribute
        /// </summary>
        /// <returns></returns>
        public async Task LoadLocations()
        {
            Working = true;
            try
            {
                if (_locations == null)
                {
                    _locations = await ItemService.ReadByDataTypeAsync(new List <string>() {
                        typeof(LocationItemData).ToString()
                    });

                    var vmLocations = new List <VMLocation>();
                    _locations.ForEach((location) =>
                    {
                        vmLocations.Add(new VMLocation()
                        {
                            ItemId      = location.Id.ToString(),
                            LocationId  = location.GetData <LocationItemData>().Id.ToString(),
                            Name        = location.GetData <VisibleItemData>().Name,
                            Description = location.GetData <VisibleItemData>().Description
                        });
                    });
                    VMLocations = vmLocations;
                }
                if (PreSelectLocation != null)
                {
                    VMSelectedLocation = VMLocations
                                         .Where(x => x.ItemId == PreSelectLocation.Value.ToString())
                                         .FirstOrDefault();
                    LocationSelected  = true;
                    PreSelectLocation = null;
                }
            }
            catch (Exception e)
            {
                LoggerService.Log("Unable to load locations", e);
                throw e;
            }
            finally
            {
                Working = false;
            }
        }
        public void TestGetCount()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString());
            var itemRepository = new EfRepository <Item>(new ApplicationDbContext(options.Options));
            var itemService    = new ItemService(itemRepository);

            itemRepository.AddAsync(new Item {
                Name = "Pizza"
            });
            itemRepository.AddAsync(new Item {
                Name = "Burger"
            });
            itemRepository.SaveChangesAsync().GetAwaiter().GetResult();

            var count = itemService.GetCount();

            Assert.Equal(2, count);
        }
예제 #25
0
        protected void btnAddDetail_Click(object sender, EventArgs e)
        {
            Page.Validate("AddDetail");
            if (Page.IsValid)
            {
                var detail = new InventoryMutationDetailViewModel();
                var item   = ItemService.Get(Convert.ToInt32(ddlItem.SelectedValue));
                detail.ItemID          = item.ID;
                detail.ItemBarcode     = item.Barcode;
                detail.ItemDescription = item.Description;
                detail.UnitName        = ddlUnit.SelectedValue;
                detail.Qty             = Convert.ToInt32(ntbQty.Value.GetValueOrDefault());
                detail.Notes           = txtNotesDetail.Text;
                detail.ID = Details.Any() ? Details.Max(d => d.ID) + 1 : 1;
                Details.Add(detail);

                RefreshDetail();
            }
        }
예제 #26
0
        public async Task Page_LoadAsync()
        {
            CurrentItem = new Item();
            int itemId;

            if (int.TryParse(Request.QueryString["ItemId"], out itemId))
            {
                using (var itemService = new ItemService())
                {
                    CurrentItem = await itemService.GetItemByIdAsync(itemId);

                    txtName.Value              = CurrentItem.Name;
                    txtPrice.Value             = CurrentItem.Price.ToString();
                    slcItemType.Value          = CurrentItem.ItemTypeId.ToString();
                    chkDefaultIncluded.Checked = CurrentItem.DefaultIncluded;
                    txtMonthsPeriod.Value      = CurrentItem.MonthsPeriod.ToString();
                }
            }
        }
예제 #27
0
        public void CanGetItemByCategory()
        {
            var mapperMoq = new Mock<IMapper>();
            var categoryDalMoq = new Mock<CategoryDal>();
            var itemDalMoq = new Mock<ItemDal>();
            categoryDalMoq
                .Setup(p => p.GetByName("name"))
                .Returns(new Category("name", "desc"));
            itemDalMoq
                .Setup(p => p.GetByFieldName(It.IsAny<string>(), It.IsAny<string>()))
                .Returns(new List<Item> { new Item("name", "desc", 1, 12, "in"));
            var service = new ItemService(itemDalMoq.Object, categoryDalMoq.Object, mapperMoq.Object);

            var result = service.GetByCategory("name");

            Assert.NotNull(result);
            Assert.Single(result);
        }
    }
예제 #28
0
        /// <summary>
        ///    Updates request status and sends out notification email
        /// </summary>
        public void SubmitRequest()
        {
            bool valid = true;

            if (this.SelectedRequest.RequestStatus == "Pending")
            {
                DialogResult dialogResult = MessageBox.Show("The status of this request is still pending. Do you wish to proceed?", "", MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.No)
                {
                    valid = false;
                }
            }
            if (valid)
            {
                try
                {
                    List <Request> requests = OptionService.RetrieveRequestList(SelectedRequest.RequestId);

                    EmailService.SendStatusChangedEmail(SelectedRequest.RequestId.ToString(), requests, SelectedRequest.UserName);
                    foreach (Request request in requests)
                    {
                        if (SelectedRequestStatus != "")
                        {
                            request.RequestStatus = SelectedRequestStatus;
                        }
                        OptionService.UpdateWebsiteRequest(request);
                        if (request.RequestStatus == "Completed")
                        {
                            ItemObject item = new ItemObject(0)
                            {
                                ItemId = request.ItemId
                            };
                            ItemService.UpdateOnSite(item, request.Website);
                        }
                    }
                    System.Windows.MessageBox.Show("Requests Submitted");
                }
                catch (Exception ex)
                {
                    ErrorLog.LogError("Odin was unable to submit the request.", ex.ToString());
                }
            }
        }
예제 #29
0
        public async Task CreateAsyncTest()
        {
            var item           = GetItem();
            var itemDto        = GetItemDto();
            var mockRepository = new Mock <IItemRepository>();
            var mockMapper     = new Mock <IMapper>();

            mockRepository.Setup(repository => repository.Create(item))
            .ReturnsAsync(item);
            mockMapper.Setup(mapper => mapper.Map <Item>(itemDto))
            .Returns(item);
            mockMapper.Setup(mapper => mapper.Map <ItemDto>(item))
            .Returns(itemDto);
            var service = new ItemService(mockMapper.Object, mockRepository.Object);

            var result = await service.CreateAsync(itemDto);

            Assert.AreEqual(itemDto, result);
        }
예제 #30
0
        public ActionResult AddItem(int itemId)
        {
            IQueueService queueService = new QueueService();
            var user = MediaSwap.Web.Models.MediaSwapIdentity.Current;

            var itemService = new ItemService();
            var item = itemService.GetItemWithOwner(itemId);

            queueService.AddItemToQueue(user.Id, itemId, item.Users.FirstOrDefault().UserId);

            SmtpClient client = new SmtpClient();
            var message = string.Format("{0} has reserved {1}.", user.FriendlyName, item.ItemName);
            client.Send(new MailMessage("*****@*****.**", item.Users.FirstOrDefault().Email) { Subject="MediaSwap Item Reserved", Body = message, IsBodyHtml = true });

            var queueItem = new MediaSwap.Web.ViewModels.SearchItemViewModel.ItemResult();
            queueItem.Status = MediaSwap.Core.Models.QueueStatus.Reserved;
            queueItem.Item  = itemService.GetItem(item.ItemId);
            return View("~/Views/Search/_ItemView.cshtml", queueItem);
        }
예제 #31
0
        public string setItemStatus()
        {
            var    itemService  = new ItemService(CurrentUserInfo);
            string content      = string.Empty;
            string error        = "停用成功";
            var    responseData = new ResponseData();

            string key = string.Empty;

            if (Request("ids") != null && Request("ids") != string.Empty)
            {
                key = Request("ids").ToString().Trim();
            }
            if (key == null || key.Length == 0)
            {
                responseData.status = "1";
                responseData.msg    = "请选择商品";
                return(responseData.ToJSON());;
            }

            var status = "-1";

            if (FormatParamValue(Request("status")) != null && FormatParamValue(Request("status")) != string.Empty)
            {
                status = FormatParamValue(Request("status")).ToString().Trim();
            }

            var idList = key.Split(',');

            foreach (var tmpId in idList)
            {
                if (tmpId.Trim().Length > 0)
                {
                    itemService.SetItemStatus(CurrentUserInfo, tmpId.Trim(), status);
                }
            }

            responseData.status = "0";
            responseData.msg    = error;

            content = responseData.ToJSON();
            return(content);
        }
예제 #32
0
        public async Task Page_LoadAsync()
        {
            CurrentExpense = new Expense();
            using (var itemService = new ItemService())
            {
                ItemsList = await itemService.GetItemsAsync();

                ItemsList.ForEach(a =>
                {
                    var listItem = new System.Web.UI.WebControls.ListItem(a.Name, a.ItemId.ToString());
                    slcItemId.Items.Add(listItem);
                    listItem.Attributes.Add("ItemTypeId", a.ItemTypeId.ToString());
                    listItem.Attributes.Add("Price", a.Price.ToString());
                    listItem.Attributes.Add("Name", a.Name);
                });
            }
            int expenseId;

            if (int.TryParse(Request.QueryString["ExpenseId"], out expenseId))
            {
                using (var expenseService = new ExpenseService())
                {
                    CurrentExpense = await expenseService.GetExpenseByIdAsync(expenseId);

                    slcItemId.Value          = CurrentExpense.ItemId.ToString();
                    txtName.Value            = CurrentExpense.Name;
                    txtPrice.Value           = CurrentExpense.Price.ToString();
                    slcRelatedMonth.Value    = CurrentExpense.RelateToMonth.ToString("d-M-yyyy");
                    txtDescription.InnerText = CurrentExpense.Description;
                    chkPayed.Checked         = CurrentExpense.Payed ?? false;
                }
            }
            else
            {
                chkPayed.Checked = true;
                using (var clientService = new ClientService())
                {
                    var client = await clientService.GetClientByIdAsync(1);

                    slcRelatedMonth.Value = client.CurrentMonth.ToString("d-M-yyyy");
                }
            }
        }
예제 #33
0
        public bool DeleteItem(string id)
        {
            ItemModelview _ItemModelview = new ItemModelview();

            using (var repo = new ItemService())
            {
                try
                {
                    var item = repo.GetById(id);
                    _ImageStoreBusiness.DeleteAllImage(id);
                    repo.Delete(item);
                    return(true);
                }
                catch (Exception)
                {
                    return(false);
                }
            }
        }
예제 #34
0
        public void Main()
        {
            int         disturbType = _.GetInventoryDisturbType();
            NWItem      item        = (_.GetInventoryDisturbItem());
            NWCreature  creature    = (_.GetLastDisturbed());
            NWPlaceable container   = (NWGameObject.OBJECT_SELF);

            if (disturbType == _.INVENTORY_DISTURB_TYPE_ADDED)
            {
                ItemService.ReturnItem(creature, item);
            }
            else if (disturbType == _.INVENTORY_DISTURB_TYPE_REMOVED)
            {
                if (!container.InventoryItems.Any())
                {
                    container.Destroy();
                }
            }
        }
예제 #35
0
        public async void GetAvalibeItemsWhenUserHasActiveBetSuccess()
        {
            var user = new DatabaseModel.User("steamId", "name", "imageUrl", "tradelink", DateTime.Now, DateTime.Now, false, null, 10);


            A.CallTo(() => _itemRepoService.FindAsync(A <DatabaseModel.User> ._)).Returns(new List <DatabaseModel.Item>
            {
                new DatabaseModel.Item("assetId1", 1, -1, -1, DateTimeOffset.Now, 10),
                new DatabaseModel.Item("assetId2", 1, -1, -1, DateTimeOffset.Now, 11),
                new DatabaseModel.Item("assetId3", 2, -1, -1, DateTimeOffset.Now, 12),
                new DatabaseModel.Item("assetId4", 3, -1, -1, DateTimeOffset.Now, 13)
            });
            A.CallTo(() => _descriptionRepoService.FindAsync(A <List <int> > ._)).Returns(new List <DatabaseModel.ItemDescription>
            {
                new DatabaseModel.ItemDescription("itemDesc1", 1, "730", "2", "img1", true, 1),
                new DatabaseModel.ItemDescription("itemDesc2", 1, "730", "2", "img1", true, 2),
                new DatabaseModel.ItemDescription("itemDesc3", 1, "730", "2", "img1", true, 3)
            });

            var match = new DatabaseModel.Match(1, "salt", "hash", 14.4.ToString(CultureInfo.InvariantCulture), 1, null, null, 1, 1, DateTime.Now, 1);
            var bets  = new List <DatabaseModel.Bet> {
                new DatabaseModel.Bet(10, 1, 1, DateTime.Now, 11)
            };

            A.CallTo(() => _matchRepoService.GetCurrentMatch()).Returns(match);
            A.CallTo(() => _betRepoService.FindAsync(A <List <LookUpGameModeBet> > ._)).Returns(bets);
            A.CallTo(() => _itemBettedRepoSerivce.FindAsync(A <List <DatabaseModel.Bet> > ._)).Returns(new List <DatabaseModel.ItemBetted>
            {
                new DatabaseModel.ItemBetted(bets[0].Id, 1, "assetId1", 1),
                new DatabaseModel.ItemBetted(bets[0].Id, 3, "assetId4", 1),
            });

            var itemService = new ItemService(_fakedRepoService);

            var avalibleItemsForUser = await itemService.GetAvalibleItemsForUser(user);


            Assert.Equal(2, avalibleItemsForUser.Count);

            Assert.Equal("itemDesc1", avalibleItemsForUser.Single(item => item.AssetId == "assetId2").Name);
            Assert.Equal("itemDesc2", avalibleItemsForUser.Single(item => item.AssetId == "assetId3").Name);
        }
예제 #36
0
        static void Main(string[] args)
        {
            MenuActionService actionService = new MenuActionService();
            ItemService       itemService   = new ItemService();
            ItemMenager       itemMenager   = new ItemMenager(actionService, itemService);

            Console.WriteLine("Witaj!!!");
            while (true)
            {
                Console.WriteLine("Wwybierz co chcesz zrobić z plikiem");
                var mainMenu = actionService.GetMenuActionsByMenuName("Main");
                for (int i = 0; i < mainMenu.Count; i++)
                {
                    Console.WriteLine($"{mainMenu[i].Id}.  {mainMenu[i].Name}");
                }

                var operation = Console.ReadKey();
                Console.Clear();
                switch (operation.KeyChar)
                {
                case '1':
                    itemMenager.AddNewItem();
                    break;

                case '2':
                    itemMenager.RemoveItem();
                    break;

                case '3':
                    itemMenager.ItemsByTypeIdView();
                    break;

                case '4':
                //var typeId = itemService.ItemTypeSeleCtionView();
                //itemService.ItemsByTypeIdView(typeId);
                //break;
                default:
                    Console.WriteLine("nieprawidłowa akcja!!");
                    break;
                }
            }
        }
예제 #37
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (cbAdress.SelectedIndex == -1)
            {
                MessageBox.Show("请选择出库口");
                return;
            }
            if (tbChooseName.Tag == null)
            {
                MessageBox.Show("请选择出库品牌");
                return;
            }
            INF_JOBDOWNLOAD job = new INF_JOBDOWNLOAD();

            job.TARGET     = address[cbAdress.SelectedIndex];
            job.SOURCE     = ((List <String>)tbChooseName.Tag)[2].ToString();
            job.BARCODE    = AtsCellInfoService.GetCellInfo(job.SOURCE).PALLETNO;
            job.PLANQTY    = int.Parse(((List <String>)tbChooseName.Tag)[1].ToString());
            job.JOBTYPE    = 50;//搬运任务
            job.PRIORITY   = 50;
            job.CREATEDATE = DateTime.Now;
            job.BRANDID    = ((List <String>)tbChooseName.Tag)[0].ToString();
            job.TUTYPE     = 4;
            job.INPUTTYPE  = 10;
            using (TransactionScope ts = new TransactionScope())
            {
                InfJobDownLoadService.InsertEntity(job);

                T_WMS_ATSCELL_CJ_HIS his = new T_WMS_ATSCELL_CJ_HIS();
                his.CELLNO        = job.SOURCE;
                his.QTY           = job.PLANQTY;
                his.INBOUNDTIME   = AtsCellInfoService.GetCellInfo(his.CELLNO).CREATETIME;
                his.CIGARETTECODE = job.BRANDID;
                his.CIGARETTENAME = ItemService.GetItemByCode(his.CIGARETTECODE).ITEMNAME;
                his.INBOUNDID     = AtsCellInfoService.GetCellInfo(his.CELLNO).INBOUNDID;
                his.BARCODE       = ItemService.GetItemByCode(his.CIGARETTECODE).BIGBOX_BAR;
                AtsCellCJService.InsertEntity(his);
                AtsCellService.UpdateAtsCell(job.SOURCE, 30);//更新cellno状态
                ts.Complete();
            }
            MessageBox.Show("出库完成");
        }
 public bool TryCreateTrapperItem(string key, string units = "", Item.ValueType valueType = Item.ValueType.NumericUnsigned, Item.DataType dataType = Item.DataType.Decimal)
 {
     if (_ItemsCache.ContainsKey(key)) return true;
     using (var context = _contextCreator())
     {
         try
         {
             var service = new ItemService(context);
             var items = service.Get(new { key_ = key, hostid = _TemplateCache.Id });
             var item = items == null || items.Count() == 0 ? null : items.First();
             if (item == null)
             {
                 item = new Item();
                 item.name = key;
                 item.key_ = key;
                 item.type = Item.ItemType.ZabbixTrapper;
                 item.value_type = valueType;
                 if (valueType == Item.ValueType.NumericUnsigned) item.data_type = dataType;
                 item.units = units;
                 item.hostid = _TemplateCache.Id;
                 var addition = new Dictionary<string, object>();
                 addition["applications"] = new string[] { _ApplicationCache.Id };
                 item.Id = service.Create(item, addition);
             }
             if (item.Id != null)
             {
                 _ItemsCache[key] = item;
                 return true;
             }
             else
             {
                 return false;
             }
         }
         catch (Exception ex)
         {
             MetricsErrorHandler.Handle(ex, string.Format("Error on configuring zabbix trapper item, zabbix api {0}", _url));
             return false;
         }
     }
 }
예제 #39
0
        private static void AddCartItem(ref Profile profile, string itemId, int quantity)
        {
            int index = 0;
            bool found = false;

            foreach (Cart cart in profile.WishList)
            {
                if (cart.ItemId == itemId)
                {
                    found = true;
                    break;
                }

                index++;
            }

            if (found)
                profile.WishList[index].Quantity += quantity;
            else
            {
                Item item = new ItemService().GetByItemId(itemId);
                Product product = new ProductService().GetByProductId(item.ProductId);
                Cart cart = new Cart
                                {
                                    UniqueId = profile.UniqueId,
                                    ItemId = itemId,
                                    Name = item.Name,
                                    ProductId = item.ProductId,
                                    IsShoppingCart = false,
                                    Price = item.ListPrice ?? item.UnitCost ?? 0,
                                    Type = product.Name,
                                    CategoryId = product.CategoryId,
                                    Quantity = quantity
                                };

                profile.WishList.Add(cart);
            }
        }
예제 #40
0
        public void SaveItem(Int32 productId, Int32 knopaId, Common.ProductType type) {
            ItemService _itemService = new ItemService();
            InventoryService _inventoryService = new InventoryService();

            ChecksMenuProductItem query = null;
            if (productId != 0 && knopaId != 0) {
                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    if (type == Common.ProductType.Alternatives) {
                        query = db.ChecksMenuProductItems.FirstOrDefault(m => m.ProductId == productId);
                        if (query != default(ChecksMenuProductItem)) {
                            query.ItemId = knopaId;
                        }
                    }
                    else if (type == Common.ProductType.Addons) {
                        query = db.ChecksMenuProductItems.FirstOrDefault(m => m.ProductId == productId && m.ItemId == knopaId);
                        if (query == default(ChecksMenuProductItem)) {
                            query = new ChecksMenuProductItem();
                            query.ItemId = knopaId;
                            query.ProductId = productId;
                            db.ChecksMenuProductItems.InsertOnSubmit(query);
                        }
                        else {
                            db.ChecksMenuProductItems.DeleteOnSubmit(query);
                        }
                    }
                    db.SubmitChanges();
                }
            }
        }
 public void UnknownItemsReturnAPriceOfZero()
 {
     var subject = new ItemService();
     var result = subject.PriceFor("something");
     Assert.That(result, Is.EqualTo(0));
 }
 public void EachIndividualItemIsPricedCorrectly(string item, int price)
 {
     var subject = new ItemService();
     var result = subject.PriceFor(item);
     Assert.That(result, Is.EqualTo(price));
 }
 void setupItemsService()
 {
     testSubject = new ItemService();
     testSubject.rewardsToTokenCount = 50;
     testSubject.itemStorage = itemStorage;
     testSubject.iapService = mockIAPService;
     testSubject.Awake();
 }
예제 #44
0
        public void Initialize()
        {
            var timeStamp = DateTime.Now;
            _item = new Item()
            {
                Id = 1,
                HeaderId = 2,
                CategoryId = 4,
                UserId = 1,
                Amount = 9400,
                Section = ItemSection.ForSale,
                Condition = ItemCondition.BrandNew,
                Warranty = ItemWarranty.Personal,
                Created = timeStamp,
                Updated = timeStamp,
                Expiry = timeStamp.AddDays(30)
            };
            _header = new Header()
            {
                Id = 2,
                UserId = 1,
                Created = timeStamp,
                Updated = timeStamp
            };

            _entry = new Entry()
            {
                Id = 3,
                HeaderId = 2,
                UserId = 1,
                Created = timeStamp,
                Updated = timeStamp
            };

            _mockUnitOfWork = new Mock<IUnitOfWork>();
            _mockItemRepository = new Mock<IRepository<Item>>();
            _mockHeaderRepository = new Mock<IRepository<Header>>();
            _mockEntryRepository = new Mock<IRepository<Entry>>();

            _mockUnitOfWork
                .Setup(uow => uow.GetRepository<Item>())
                .Returns(_mockItemRepository.Object);
            _mockUnitOfWork
                .Setup(uow => uow.GetRepository<Header>())
                .Returns(_mockHeaderRepository.Object);
            _mockUnitOfWork
                .Setup(uow => uow.GetRepository<Entry>())
                .Returns(_mockEntryRepository.Object);
            _mockUnitOfWork
                .Setup(u => u.Commit())
                .Returns(3);
            _mockItemRepository
                .Setup(r => r.Insert(It.IsAny<Item>()))
                .Returns(_item);
            _mockHeaderRepository
                .Setup(r => r.Insert(It.IsAny<Header>()))
                .Returns(_header);
            _mockEntryRepository
                .Setup(r => r.Insert(It.IsAny<Entry>()))
                .Returns(_entry);

            _sut = new ItemService(
                _mockHeaderRepository.Object,
                _mockItemRepository.Object,
                _mockEntryRepository.Object);
        }
예제 #45
0
 protected override void Initialize()
 {
     base.Initialize();
     this._itemService = this.RootDomain.ItemService.Get();
 }
 void setupItemsService()
 {
     itemService = new ItemService();
     itemService.rewardsToTokenCount = 50;
     itemService.itemStorage = new MemoryItemStorage();
     itemService.iapService = new MockIAPService();
     itemService.Awake();
 }
        public void GetIdIfItemIsNullThrowException()
        {
            IItemService itemService = new ItemService();

            Assert.Throws<ArgumentNullException>(() => { itemService.GetId(null); });
        }
예제 #48
0
        public Boolean UpdateInventory(Int32 checkId) {
            List<Services.ChecksMenu> menus;
            List<ChecksMenuProduct> products;
            ItemService _itemService = new ItemService();
            InventoryService _inventoryService = new InventoryService();

            try {
                menus = GetMenuItems(checkId);

                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    Check check = db.Checks.Where(m => m.id == checkId).FirstOrDefault();
                    foreach (Services.ChecksMenu menuItem in menus) {
                        /// We need to make sure that we are not double logging inventory
                        if (!db.InventoryRegistryCheckMenus.Any(m => m.ChecksMenuId == menuItem.id)) {
                            Item itemMenu = _itemService.GetItem(menuItem.MenuId);
                            foreach (ItemInventoryAssociation association in itemMenu.ItemInventoryAssociations) {
                                _inventoryService.AddInventoryRegistry(association, menuItem);
                            }

                            products = GetProducts(menuItem.id);
                            if (products.Any()) {
                                foreach (Services.ChecksMenuProduct productItem in products) {
                                    foreach (Services.ChecksMenuProductItem associatedItem in productItem.ChecksMenuProductItems) {
                                        Item prodItem = _itemService.GetItemProductAssosiationsById(associatedItem.ItemId);
                                        foreach (ItemInventoryAssociation association in prodItem.ItemInventoryAssociations) {
                                            _inventoryService.AddInventoryRegistry(association, menuItem);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }

                return true;
            }
            catch (Exception ex) {
                return false;
            }
        }
예제 #49
0
        public ChecksMenu SaveMenuItem(Item menuItem, Int32 tableId, Int32 orderId, Int32 userId) {
            ItemService _itemService = new ItemService();
            InventoryService _inventoryService = new InventoryService();

            ChecksMenu orderCheckMenu;
            try {
                using (menuzRusDataContext db = new menuzRusDataContext(base.connectionString)) {
                    // New order
                    TableOrder tableOrder = db.TableOrders.FirstOrDefault(m => m.TableId == tableId && m.Status != (Int32)Common.TableOrderStatus.Closed);
                    if (tableOrder == default(TableOrder)) {
                        tableOrder = new TableOrder();
                        tableOrder.TableId = tableId;
                        tableOrder.Status = (Int32)Common.TableOrderStatus.Open;
                        db.TableOrders.InsertOnSubmit(tableOrder);
                        db.SubmitChanges();
                    }

                    Check orderCheck = db.Checks.FirstOrDefault(m => m.id == orderId);
                    if (orderCheck == default(Check)) {
                        orderCheck = new Check();
                        orderCheck.TableOrderId = tableOrder.id;
                        orderCheck.Type = (Int32)Common.CheckType.Guest;
                        orderCheck.Status = (Int32)Common.CheckStatus.Active;
                        orderCheck.UserId = userId;
                        db.Checks.InsertOnSubmit(orderCheck);
                        db.SubmitChanges();
                    }

                    orderCheckMenu = new ChecksMenu();
                    orderCheckMenu.CheckId = orderCheck.id;
                    orderCheckMenu.MenuId = menuItem.id;
                    orderCheckMenu.Status = (Int32)Common.MenuItemStatus.Active;
                    db.ChecksMenus.InsertOnSubmit(orderCheckMenu);
                    db.SubmitChanges();

                    foreach (ItemProduct itemProduct in menuItem.ItemProducts) {
                        ChecksMenuProduct product = new ChecksMenuProduct();
                        product.CheckMenuId = orderCheckMenu.id;
                        product.ItemId = itemProduct.id;
                        db.ChecksMenuProducts.InsertOnSubmit(product);
                        db.SubmitChanges();
                        if (itemProduct.ItemProductAssociations.Count() > 0) {
                            ChecksMenuProductItem item = new ChecksMenuProductItem();
                            item.ProductId = product.id;
                            item.ItemId = itemProduct.ItemProductAssociations[0].id;
                            db.ChecksMenuProductItems.InsertOnSubmit(item);
                            db.SubmitChanges();
                        }
                    }
                }
            }
            catch (Exception ex) {
                return null;
            }
            return orderCheckMenu;
        }
예제 #50
0
 public ItemFactory()
 {
     _itemService = _itemService ?? new ItemService();
 }