public ResultDto Add(WareDto dto)
 {
     try
     {
         Ware ware = new Ware()
         {
             Name        = dto.Name,
             Image       = dto.Image,
             Price       = dto.Price,
             Description = dto.Description
         };
         _context.Wares.Add(ware);
         _context.SaveChangesAsync();
         return(new ResultDto
         {
             IsSuccessful = true,
             Message = "Succesfully created"
         });
     }
     catch (Exception ex)
     {
         return(new ResultDto
         {
             IsSuccessful = false,
             Message = "Error"
         });
     }
 }
Beispiel #2
0
        private void Btn_add_ware_Click(object sender, EventArgs e)
        {
            Ware ware = new Ware();

            ware.warecode    = txtwarecode.Text;
            ware.warename    = txtwarename.Text;
            ware.enable      = checkBox1.Checked;
            ware.rowcount    = Convert.ToInt32(txtrowcount.Text);
            ware.columncount = Convert.ToInt32(txtcolumncount.Text);
            ware.layercount  = Convert.ToInt32(txtlayercount.Text);

            WareManage.AddWare(ware);

            for (int i = 1; i <= ware.rowcount; i++)
            {
                for (int j = 1; j <= ware.columncount; j++)
                {
                    for (int k = 1; k <= ware.layercount; k++)
                    {
                        Point point = new Point();
                        point.pointcode  = ware.warecode + "_" + i.ToString("00") + j.ToString("00") + k.ToString("00");
                        point.areacode   = "";
                        point.pointstate = "";
                        point.warecode   = ware.warecode;
                        PointManage.AddPoint(point);
                    }
                }
            }


            MessageBox.Show("添加成功!");
            Close();
        }
        public ResultDto Edit([FromBody] WareDto dto)
        {
            try
            {
                Ware w = _context.Wares.First(x => x.Id == dto.Id);
                w.Name        = dto.Name;
                w.Image       = dto.Image;
                w.Price       = dto.Price;
                w.Description = dto.Description;
                _context.SaveChanges();
                return(new ResultDto
                {
                    IsSuccessful = true,
                    Message = "Successfully created"
                });
            }
            catch (Exception)
            {
                return(new ResultDto
                {
                    IsSuccessful = false,
                    Message = "Something goes wrong!"
                });

                throw;
            }
        }
        public void ShouldCreateWareBooking()
        {
            var now    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.AddDays(1).Day, 10, 0, 0, 0);
            var input  = new CreateWareBookingInput(0, 0, now, now.Date.AddHours(1));
            var domain = new WareBooking(0, 0, now, now.AddHours(1));

            var mockWareBookingRepo = new Mock <IWareBookingRepository>();

            mockWareBookingRepo.Setup(m => m.GetStartingAt(now.Date)).Returns(new List <WareBooking>());
            mockWareBookingRepo.Setup(m => m.Create(domain)).Returns(0);

            var ware         = new Ware("test", "test", "e1234fjdgq84324", 0, false);
            var mockWareRepo = new Mock <IWareRepository>();

            mockWareRepo.Setup(m => m.GetById(0)).Returns(ware);

            var mockTimeSlotRepo = new Mock <ITimeSlotRepository>();

            mockTimeSlotRepo.Setup(m => m.GetAllOfPlace(0)).Returns(new List <TimeSlot> {
                new TimeSlot(now.DayOfWeek, 8, 0, 20, 0, 0)
            });

            var res = new CreateWareBooking(mockWareBookingRepo.Object, mockTimeSlotRepo.Object, mockWareRepo.Object,
                                            input).Execute();

            Assert.AreEqual(0, res);
        }
Beispiel #5
0
        public int Create(Ware ware, Decimal TimeLimit, bool Active)
        {
            int result = 1;

            IEnumerable <WareTimeLimit> timeLimitsExists = ware.WareTimeLimits.Where(a => a.Active == true & a.TimeLimit != TimeLimit);

            if (timeLimitsExists != null)
            {
                if (timeLimitsExists.Count() > 0)
                {
                    foreach (WareTimeLimit limit in timeLimitsExists)
                    {
                        if (limit.TimeLimit != TimeLimit)
                        {
                            limit.Active = false;
                        }
                    }
                }
            }
            IEnumerable <WareTimeLimit> currentTimeLimitsExists = ware.WareTimeLimits.Where(a => a.Active == true & a.TimeLimit == TimeLimit);

            if (currentTimeLimitsExists.Count() == 0)
            {
                WareTimeLimit sr = new WareTimeLimit();
                sr.TimeLimit = TimeLimit;
                sr.Active    = Active;
                ware.WareTimeLimits.Add(sr);
                context.AddToWareTimeLimits(sr);
            }
            return(result);
        }
Beispiel #6
0
        public async Task <IActionResult> Bearbeiten(BearbeitenViewModel model)
        {
            if (ModelState.IsValid)
            {
                var  userID = usernManager.GetUserId(HttpContext.User);
                Ware ware   = new Ware
                {
                    Ware_Id                = model.Ware_Id,
                    Ware_Beschreibung      = model.Ware_Beschreibung_NEU,
                    Ware_Einlagerungsdatum = model.Ware_Einlagerungsdatum,
                    Lagerplatz_Id          = model.Lagerplatz_NEU,
                    Menge           = model.Menge_NEU,
                    Seriennr        = model.Seriennummer_NEU,
                    Modellnummer    = model.Modellnummer_NEU,
                    Kategorie_Name  = model.Kategorie_NEU,
                    Anschaff_Kosten = model.Anschaffungskosten_NEU,
                    Lieferant_Id    = model.Lieferant_NEU,
                    Kostenstelle_Nr = model.Kostenstelle_NEU,
                    Hersteller_Id   = model.Hersteller_NEU,
                    Auftragsnummer  = model.Auftragsnummer_NEU,
                };

                _context.Ware.Update(ware);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Details", new { id = model.Ware_Id }));
            }
            return(View(model));
        }
Beispiel #7
0
        public ActionResult Sell(SellPlayerPartModel bindModel)
        {
            var username = this.User.Identity.Name;

            var playerPart = this.partsService.GetPlayerPartByPartId(username, bindModel.PartId);

            if (playerPart == null)
            {
                this.TempData["Error"] = "Part not found!";
                return(RedirectToAction(nameof(Inventory)));
            }

            mapper.Map <Part, SellPlayerPartModel>(playerPart.Part, bindModel);

            if (!ModelState.IsValid)
            {
                return(View(bindModel));
            }


            var ware = new Ware()
            {
                PlayerPartId = playerPart.Id,
                ListedOn     = DateTime.UtcNow,
                Price        = (decimal)bindModel.Price,
            };

            this.waresService.AddWare(ware);
            this.playersService.SetPartForSale(playerPart.Id);

            return(RedirectToAction(nameof(Inventory)));
        }
Beispiel #8
0
        public WareDocumentDetail CreateWithNoSave(int WareID, decimal UnitQuantity, decimal?SecondaryUnitQuantity,
                                                   decimal PriceForUnit, decimal?DiscountForUnit,
                                                   decimal?EndPriceForUnit, decimal EndPrice, int CurrencyID, int PriceGroupID)
        {
            int userId            = Compas.Logic.Security.CurrentSecurityContext.Identity.ID;
            WareDocumentDetail sr = new WareDocumentDetail();

            //sr.WareID = WareID;

            Wares.WaresLogic wares = new Wares.WaresLogic(manager);
            Ware             ware  = wares.Get(WareID);

            ware.WareDocumentDetails.Add(sr);
            //sr.WareID = WareID;
            sr.UnitQuantity = UnitQuantity;
            if (SecondaryUnitQuantity != null)
            {
                sr.SecondaryUnitQuantity = Convert.ToDecimal(SecondaryUnitQuantity);
            }
            sr.DiscountForUnit = DiscountForUnit;
            sr.CurrencyID      = CurrencyID;
            sr.EndPrice        = EndPrice;
            sr.EndPriceForUnit = EndPriceForUnit;
            sr.PriceForUnit    = PriceForUnit;



            return(sr);
        }
Beispiel #9
0
 public override void Setup(Ware ware, BasicChar buyer)
 {
     if (ware is BuyMeal meal)
     {
         this.meal  = meal;
         this.buyer = buyer;
         Cost       = meal.Cost;
         SetTexts(meal.Title, meal.Desc, meal.Cost.ToString());
         BuyBtn.onClick.AddListener(Buy);
         FrameCanAfford();
         buyer.Currency.GoldChanged += FrameCanAfford;
         if (meal.Img != null)
         {
             icon.sprite = meal.Img;
         }
         else
         {
             icon.gameObject.SetActive(false);
         }
     }
     else
     {
         Destroy(gameObject);
     }
 }
Beispiel #10
0
        public ActionResult Sell(int partId)
        {
            var player = this.playersService.GetPlayerByUsername("OfficialStore");
            var part   = this.partsService.GetPartById(partId);

            if (part == null)
            {
                this.TempData["Error"] = "Part not found!";
                return(RedirectToAction(nameof(Menu)));
            }

            var playerPart = player.Inventory.FirstOrDefault(x => x.PartId == partId);

            if (!playerPart.IsForSale)
            {
                this.playersService.SetPartForSale(playerPart.Id);
                var ware = new Ware()
                {
                    PlayerPart = playerPart,
                    ListedOn   = DateTime.UtcNow,
                    Price      = part.BasePrice,
                };

                this.waresService.AddWare(ware);
            }

            return(RedirectToAction("Index", "Store"));
        }
Beispiel #11
0
        private void FillFields()
        {
            _unitQuantity          = detail.UnitQuantity;
            _secondaryUnitQuantity = detail.SecondaryUnitQuantity;
            _priceForUnit          = detail.PriceForUnit;
            _endPriceForUnit       = detail.EndPriceForUnit;
            _endPrice     = detail.EndPrice;
            _currencyName = (detail.WareDocument == null ? "" : detail.WareDocument.Currency.Name);

            if (detail.Ware != null)
            {
                _wareName          = detail.Ware.Name;
                _unitName          = detail.Ware.WareUnit == null ? "" : detail.Ware.WareUnit.Name;
                _secondaryUnitName = detail.Ware.WareUnit1 == null ? "" : detail.Ware.WareUnit1.Name;
                _unit          = _unitQuantity + " " + (detail.Ware.WareUnit == null ? "" : detail.Ware.WareUnit.Name);
                _secondaryUnit = detail.SecondaryUnitQuantity.ToString() + " " + (detail.Ware.WareUnit1 == null ? "" : detail.Ware.WareUnit1.Name);
            }
            else
            {
                WaresLogic waresLogic = new WaresLogic(manager);
                Ware       ware       = waresLogic.Get(detail.WareID);
                if (ware != null)
                {
                    _wareName = ware.Name;
                }
            }
        }
Beispiel #12
0
        public void RemoveWareById_ShouldRemoveCorrectWare()
        {
            var options = GetDbOptions("RemoveWareById_Database");

            var dummyWare1 = new Ware() { Id = 12 };
            var dummyWare2 = new Ware() { Id = 23 };

            using (var context = new RiderDBContext(options))
            {
                context.Wares.Add(dummyWare1);
                context.Wares.Add(dummyWare2);
                context.SaveChanges();
            }

            List<Ware> actual;
            using (var context = new RiderDBContext(options))
            {
                var waresService = new WaresService(context);
                waresService.RemoveWareById(23);
                actual = context.Wares.ToList();
            }

            Assert.Single(actual);
            Assert.Contains(actual, x => x.Id == 12);
            Assert.DoesNotContain(actual, x => x.Id == 23);
        }
Beispiel #13
0
        /// <summary>
        /// Додавання позицій в документ по коду одиниці
        /// </summary>
        /// <param name="WareCode"></param>
        /// <returns></returns>
        private WareDocumentDetail AddDocumenDetailByWareCode(string WareCode)
        {
            DocumentDetailsLogic details        = new DocumentDetailsLogic(manager);
            WareCodesLogic       wareCodesLogic = new WareCodesLogic(manager);
            WareDocumentDetail   result         = null;
            Ware ware = wareCodesLogic.GetWareByCode(WareCode);

            if (ware != null)
            {
                int     wareId                = ware.ID;
                decimal unitQuantity          = 1;
                decimal secondaryUnitQuantity = 0;
                decimal priceForUnit          = 0;
                decimal discountForUnit       = 0;
                decimal endSalePriceForUnit   = 0;
                decimal endPrice              = 0;

                int currencyId   = Convert.ToInt32(CurrencyLUE.EditValue);
                int priceGroupID = 1;

                WareDocumentDetail DocumentDetail = new WareDocumentDetail();
                //створюємо новий запис в деталізації документа і повертаємо його
                DocumentDetail = details.CreateWithNoSave(wareId, unitQuantity, secondaryUnitQuantity,
                                                          priceForUnit, discountForUnit, endSalePriceForUnit, endPrice, currencyId, priceGroupID);
                documentDetailsView.Add(DocumentDetail);
                result = DocumentDetail;
                FillDetails();
            }
            else
            {
                MessageBox.Show("Товар з даним кодом не знайдено");
            }
            return(result);
        }
Beispiel #14
0
        //public ActionResult List(string category, int page = 1)
        //{
        //    WaresListViewModel model = new WaresListViewModel
        //    {
        //        Wares = repos.Wares
        //    .Where(p => category == null || p.Category == category)
        //    .OrderBy(game => game.ID)
        //    .Skip((page - 1) * pageSize)
        //    .Take(pageSize),
        //        PagingInfo = new PagingInfo
        //        {
        //            CurrentPage = page,
        //            ItemsPerPage = pageSize,
        //            TotalItems = category == null ?
        //repos.Wares.Count() :
        //repos.Wares.Where(game => game.Category == category).Count()
        //        },
        //        CurrentCategory = category
        //    };
        //    return View(model);
        //}

        public ViewResult EditWare(int Id)
        {
            Ware ware = repos.Wares
                        .FirstOrDefault(g => g.ID == Id);

            return(View(ware));
        }
Beispiel #15
0
        public Ware AddWare(Ware ware)
        {
            this.context.Wares.Add(ware);
            this.context.SaveChanges();

            return(ware);
        }
Beispiel #16
0
        public async Task <ActionResult <Ware> > PostWare(Ware ware)
        {
            _context.Wares.Add(ware);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetWare", new { id = ware.Id }, ware));
        }
Beispiel #17
0
        public void GetWareById_ShouldReturnCorrectWare()
        {
            var options = GetDbOptions("GetWareById_Database");

            var dummyPlayer = new Player();
            var dummyPart = new Part();
            var dummyPlayerPart = new PlayerParts() { Player = dummyPlayer, Part = dummyPart };

            var dummyWare1 = new Ware() { PlayerPart = dummyPlayerPart };
            var dummyWare2 = new Ware() { PlayerPart = dummyPlayerPart };

            using (var context = new RiderDBContext(options))
            {
                context.Wares.Add(dummyWare1);
                context.Wares.Add(dummyWare2);
                context.SaveChanges();
            }

            Ware actual;
            using (var context = new RiderDBContext(options))
            {
                var waresService = new WaresService(context);
                actual = waresService.GetWareById(dummyWare1.Id);
            }

            Assert.Equal(dummyWare1.Id, actual.Id);
        }
Beispiel #18
0
        // POST: Waren/Delete/5
        public ActionResult Delete(Guid id)
        {
            Ware ware = _db.Waren.Find(id);

            if (ware == null)
            {
                return(HttpNotFound());
            }

            var lagerWarenIdList = ware.LagerWaren.Select(x => x.LagerWarenID).ToList();

            foreach (var guid in lagerWarenIdList)
            {
                var lagerWare = _db.LagerWaren.Find(guid);

                if (lagerWare != null)
                {
                    _db.LagerWaren.Remove(lagerWare);
                }
            }

            _db.Waren.Remove(ware);
            _db.SaveChanges();

            return(RedirectToAction("Index"));
        }
Beispiel #19
0
        public async Task <IActionResult> PutWare(int id, Ware ware)
        {
            if (id != ware.Id)
            {
                return(BadRequest());
            }

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

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WareExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Beispiel #20
0
        public void GetLatestWare_ShouldReturnLastWareByListedOn()
        {
            var options = GetDbOptions("GetLatestWare_Database");

            var dummyPlayer = new Player();
            var dummyPart = new Part();
            var dummyPlayerPart = new PlayerParts() { Player = dummyPlayer, Part = dummyPart };

            var dummyWare1 = new Ware() { PlayerPart = dummyPlayerPart, ListedOn = DateTime.UtcNow };
            var dummyWare2 = new Ware() { PlayerPart = dummyPlayerPart, ListedOn = DateTime.UtcNow };

            using (var context = new RiderDBContext(options))
            {
                context.Wares.Add(dummyWare2);
                context.Wares.Add(dummyWare1);
                context.SaveChanges();
            }

            Ware actual;
            using (var context = new RiderDBContext(options))
            {
                var waresService = new WaresService(context);
                actual = waresService.GetLatestWare();
            }

            Assert.Equal(dummyWare2.Id, actual.Id);
        }
Beispiel #21
0
        /// <inheritdoc />
        public Ware Add(Ware ware)
        {
            var id       = _db.Wares.Last().Id + 1;
            var wareTest = new WareTest(id, ware);

            _db.Wares.Add(wareTest);
            return(wareTest);
        }
Beispiel #22
0
        /// <summary>
        /// Take specific ware from store
        /// </summary>
        /// <param name="ware">Specific ware in store</param>
        /// <returns>Founded and removed ware or null</returns>
        public Ware Take(Ware ware)
        {
            CheckExpires();
            var entity = _repo.Remove(ware);

            WareTaked(ware);
            return(entity);
        }
        public long Create(Ware ware)
        {
            var id = Wares.Count;

            ware.Id = id;
            Wares.Add(ware);
            return(id);
        }
Beispiel #24
0
 public WareDetailVm(Page view, Ware openWare)
 {
     this.view = view;
     Ware      = openWare;
     Items     = new ObservableCollection <Ware>
     {
         openWare
     };
 }
Beispiel #25
0
        public async Task <IActionResult> Buchen(BuchenViewModel model)
        {
            if (string.IsNullOrEmpty(model.Seriennr))
            {
                model.Seriennr = "0";
            }
            else
            {
                model.Menge = 1;
            }

            if (string.IsNullOrEmpty(model.Modellnummer))
            {
                model.Modellnummer = "0";
            }

            if (ModelState.IsValid)
            {
                var  userID = usernManager.GetUserId(HttpContext.User);
                Ware ware   = new Ware
                {
                    Ware_Beschreibung      = model.Ware_Beschreibung,
                    Ware_Einlagerungsdatum = DateTime.Today,
                    Lagerplatz_Id          = model.Lagerplatz_Id,
                    Menge           = model.Menge,
                    User_id         = userID,
                    Seriennr        = model.Seriennr,
                    Modellnummer    = model.Modellnummer,
                    Kategorie_Name  = model.Kategorie_Name,
                    Lieferant_Id    = model.Lieferant_Id,
                    Hersteller_Id   = model.Hersteller_Id,
                    Kostenstelle_Nr = model.Kostenstelle_Id,
                    Anschaff_Kosten = model.Anschaff_Kosten,
                    Auftragsnummer  = model.Auftragsnummer
                };

                _context.Ware.Add(ware);
                await _context.SaveChangesAsync();

                return(RedirectToAction("Index"));
            }
            model.Lagerplatz = _context.Lagerplatz.OrderBy(i => i.Lagerplatz_Beschreibung).ToList();
            var ware1 = _context.Ware;

            foreach (var i in ware1)
            {
                model.Lagerplatz.RemoveAll(s => s.Lagerplatz_Id == i.Lagerplatz_Id);
            }
            model.Kategorie = _context.Kategorie.ToList();

            model.Kategorie    = _context.Kategorie.ToList();
            model.Hersteller   = _context.Hersteller.ToList();
            model.Kostenstelle = _context.Kostenstelle.ToList();
            model.Lieferant    = _context.Lieferant.ToList();

            return(View(model));
        }
Beispiel #26
0
 /// <inheritdoc />
 public Ware Remove(Ware ware)
 {
     if (ware != null && Exists(ware.Id))
     {
         _db.Wares.Remove(ware);
         _db.SaveChanges();
     }
     return(ware);
 }
Beispiel #27
0
        /// <summary>
        /// Add new ware in store
        /// </summary>
        /// <param name="ware">Ware</param>
        /// <returns>Added ware</returns>
        public Ware Store(WareValue ware)
        {
            var entity = new Ware(ware);

            entity = _repo.Add(entity);
            WareStored(entity);
            CheckExpires();
            return(entity);
        }
Beispiel #28
0
        public IActionResult Update([FromBody] Ware ware)
        {
            var res = new UpdateWare(repository, ware).Execute();

            if (res == -1)
            {
                return(Conflict());
            }
            return(Ok(res));
        }
Beispiel #29
0
        public RedirectToRouteResult AddToCart(Cart cart, int Id, string returnUrl)
        {
            Ware ware = repos.Wares
                        .FirstOrDefault(g => g.ID == Id);

            if (ware != null)
            {
                cart.AddItem(ware, 1);
            }
            return(RedirectToAction("Index", new { returnUrl }));
        }
Beispiel #30
0
        public ActionResult DeleteWare(int Id)
        {
            Ware deletedWare = repos.DeleteWare(Id);

            if (deletedWare != null)
            {
                TempData["message"] = string.Format("Товар \"{0}\" був видалений",
                                                    deletedWare.Name);
            }
            return(RedirectToAction("Index"));
        }
 bool erstelleWarenBewegung(Ware ware, Warenbewegung bewegung)
 {
 }
Beispiel #32
0
        private int insertWareIntoDb(Ware ware)
        {
            SqlCommand cmd = new SqlCommand("INSERT INTO wares(description,weightPerPallet,nrOfPallets) VALUES (@description,@weightPerPallet,@nrOfPallets)", Database.sqlCon);
            try
            {
                cmd.Parameters.Add("@description", SqlDbType.Text).Value = ware.Description;
                cmd.Parameters.Add("weightPerPallet", SqlDbType.Int).Value = ware.WeightPerPallet;
                cmd.Parameters.Add("@nrOfPallets", SqlDbType.Int).Value = ware.NrOfPallets;
                cmd.ExecuteNonQuery();
            }
            catch(Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }

            //now it needs to get back the wareId

            SqlCommand command = new SqlCommand("SELECT IDENT_CURRENT('wares')", Database.sqlCon);
            ware.WareId=Convert.ToInt32(command.ExecuteScalar());

            return ware.WareId;
        }
 bool loescheWare(Ware ware)
 {
 }
Beispiel #34
0
        public Ware makeNewWare(string description, int weightPerPallet, int nrOfPallets)
        {
            Ware ware = new Ware();
            ware.Description = description;
            ware.WeightPerPallet = weightPerPallet;
            ware.NrOfPallets = nrOfPallets;

            return ware;
        }
 bool aktualisiereWare(Ware ware)
 {
 }
Beispiel #36
0
        public int getPrice(Ware ware)
        {
            Database.sqlCon.Open();

            int price = 0;
            //selecting the right price
            SqlCommand command = new SqlCommand("SELECT price FROM prices WHERE kgPerPalletFrom<=" + ware.WeightPerPallet + " AND kgPerPalletTo> " + ware.WeightPerPallet, Database.sqlCon);
            SqlDataReader dataReader = command.ExecuteReader();

            if (dataReader.HasRows)
            {
                while (dataReader.Read())
                {
                    price = dataReader.GetInt32(0);
                }
            }

            Database.sqlCon.Close();
            return price;
        }
 bool erstelleWare(Ware ware)
 {
 }