示例#1
0
文件: Program.cs 项目: zeynepidil/HW5
        static void Main(string[] args)
        {
            Customer customer1 = new Customer()
            {
                FirstName = "İdil", LastName = "Erkal", YearofBirth = 1999, IdentityNumber = 123
            };
            Customer customer2 = new Customer()
            {
                FirstName = "İrem", LastName = "Erkal", YearofBirth = 1991, IdentityNumber = 124
            };

            CustomerManager customerManager = new CustomerManager();

            customerManager.Add(customer1);
            customerManager.Add(customer2);
            customerManager.Delete(customer2);
            customerManager.Update(customer1);
            customerManager.Update(customer2);



            Campaign campaign1 = new Campaign()
            {
                CampaignName = "Campaign1", DiscountRate = 50
            };
            Campaign campaign2 = new Campaign()
            {
                CampaignName = "Campaign2", DiscountRate = 70
            };

            CampaignManager campaignManager = new CampaignManager();
            {
                campaignManager.Add(campaign1);
                campaignManager.Delete(campaign1);
                campaignManager.Add(campaign2);
                campaignManager.Delete(campaign2);
            }
            SaleManager saleManager = new SaleManager();
            {
                saleManager.Add(new Entities.Sale {
                    GameName = "VALORANT", GamePrice = 500
                }, customer1, campaign1);
                saleManager.Add(new Entities.Sale {
                    GameName = "lol", GamePrice = 600
                }, customer2, campaign2);
            }
        }
示例#2
0
        static void Main(string[] args)
        {
            GamerManager gamerManager = new GamerManager(new UserValidationManager());

            gamerManager.Add(new Gamer {
                Id = 1, BirthYear = 1996, FirstName = "merve", LastName = "teke", IdentityNumber = 123456789
            });
            gamerManager.Delete(new Gamer {
                Id = 1, BirthYear = 1996, FirstName = "merve", LastName = "teke", IdentityNumber = 123456789
            });
            gamerManager.Update(new Gamer {
                Id = 2, BirthYear = 1996, FirstName = "merve", LastName = "teke", IdentityNumber = 123456789
            });



            CampaignManager campaignManager  = new CampaignManager();
            CampaignManager campaignManager1 = new CampaignManager();

            campaignManager.Add(new Campaign()
            {
                Id           = 1,
                CampaignName = "Yaz Kampanyası",
                CampaignType = "Öğrenci İndirimi",
            });
            campaignManager1.Delete(new Campaign()
            {
                Id           = 2,
                CampaignName = "Kış Kampanyası",
                CampaignType = "Çalışan İndirimi",
            });
            campaignManager1.Update(new Campaign()
            {
                Id           = 3,
                CampaignName = "Bahar Kampanyası",
                CampaignType = "Herkes İçin İndirim",
            });

            Game game = new Game()
            {
                GameName  = "Flappy bird",
                GamePrice = 30,
            };

            SaleManager saleManager = new SaleManager(new CampaignManager());

            saleManager.Add(new Gamer {
                Id = 1
            }, new Game {
                GameName = "Flappy"
            }, new Campaign {
                CampaignName = "Kış Kampanyası"
            });
        }
示例#3
0
        public JsonResult AddSales(int CustomerID, string Date, double Loyalitypoint, double Grandtotal, double Discount)
        {
            var    sales    = _saleManager.GetAll().ToList();
            string salecode = "";

            if (sales.Count() > 0)
            {
                var code = (from sa in sales orderby sa.Id descending select sa.Code).First();
                salecode = code.ToString();
                //salecode = code.ToString();
                string sub = salecode.Substring(5, 4);
                int    c   = Convert.ToInt32(sub);
                c++;
                string s = c.ToString("0000");
                salecode = "2019-" + s;
            }
            else
            {
                salecode = "2019-0001";
            }

            Sale sale = new Sale();

            sale.CustomerId = CustomerID;
            sale.Date       = Date;


            sale.Code = salecode;

            _saleManager.Add(sale);

            double          loyalityPointIncrease = (Loyalitypoint + (Grandtotal / 1000));
            double          updateLoyalitypoint   = (loyalityPointIncrease - Discount);
            List <Customer> customers             = _customerManager.GetAll().Where(c => c.Id == CustomerID).ToList();

            foreach (var c in customers)
            {
                customer.Id      = c.Id;
                customer.Name    = c.Name;
                customer.Code    = c.Code;
                customer.Contact = c.Contact;
                customer.Email   = c.Email;
                customer.Address = c.Address;
            }
            customer.LoyalityPoint = updateLoyalitypoint;
            _customerManager.Update(customer);


            var productList = _saleManager.GetAll().Where(c => c.Code == salecode).ToList();
            var salesId     = from s in productList select(s.Id);


            return(Json(salesId, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(Sale sale)
        {
            JsonResult jason = new JsonResult();

            if (ModelState.IsValid)
            {
                jason.Data = _saleManager.Add(sale)
                    ? new { Success = true, Message = "Saved Successfully" }
                    : new { Success = true, Message = "Unable to Save" };
            }


            return(RedirectToAction("Index"));
        }
        //public JsonResult AddSalesDetails(string ProductCode, int Quantity, int MRP, int TotalMRP)
        public JsonResult AddSales(int CustomerID, string Date, int Loyalitypoint)
        {
            Sale sale = new Sale();

            sale.CustomerId = CustomerID;
            sale.Date       = Date;
            string value = "2030";

            sale.Code = value;

            _saleManager.Add(sale);


            var productList = _saleManager.GetAll().Where(c => c.Code == value).ToList();
            var salesId     = from s in productList select(s.Id);


            return(Json(salesId, JsonRequestBehavior.AllowGet));
        }
示例#6
0
        public void AddNewSaleV1()
        {
            //Setup
            var sale = new Sale()
            {
                SaleDate       = DateTime.Now,
                ProductStockId = list.ElementAt(1).ProductStockId,
                ProductStock   = list.ElementAt(1),
                Amount         = 10,
                SaleState      = SaleState.PendingLiquidate
            };


            var saleManager = new SaleManager(dataServiceMock.Object);


            //Asserts
            Assert.ThrowsException <Exception>(() => saleManager.Add(sale));
        }
示例#7
0
        static void Main(string[] args)
        {
            GamerManager gamerManager = new GamerManager(new UserValidationManager());

            gamerManager.Add(new Gamer
            {
                Id             = 1,
                BirthYear      = new DateTime(1988),
                FirstName      = "ETHEM ANIL",
                LastName       = "SANDALCI",
                IdentityNumber = 12345
            });

            GameManager gameManager = new GameManager();

            gameManager.Add(new Game
            {
                Id           = 3,
                ProductName  = "Diablo III",
                ProductPrice = 19
            });

            OfferManager offerManager = new OfferManager();

            offerManager.Add(new Offer
            {
                Id        = 5,
                OfferName = "Legend Of Summer",
                Discount  = 30
            });

            SaleManager salesManager = new SaleManager();

            salesManager.Add(new Gamer {
                FirstName = "ETHEM ANIL, "
            }, new Game {
                ProductName = "Diablo, "
            }, new Offer {
                OfferName = "Legend Of Summer"
            });
        }
示例#8
0
        public void AddNewSale()
        {
            //Setup
            var sale = new Sale()
            {
                SaleDate       = DateTime.Now,
                ProductStockId = list.ElementAt(0).ProductStockId,
                ProductStock   = list.ElementAt(0),
                Amount         = 8,
                SalePrice      = 1.00,
                SaleState      = SaleState.PendingLiquidate
            };

            dataServiceMock.Setup(m => m.Insert <Sale>(It.IsAny <Sale>()))
            .Returns(new Sale()
            {
                SaleId         = 1,
                Amount         = sale.Amount,
                SaleDate       = sale.SaleDate,
                SalePrice      = sale.SalePrice,
                SaleState      = SaleState.PendingLiquidate,
                ProductStockId = list.ElementAt(0).ProductStockId,
                ProductStock   = list.ElementAt(0)
            })
            .Verifiable();

            var saleManager = new SaleManager(dataServiceMock.Object);
            //Act

            var saleExpected = saleManager.Add(sale);


            //Asserts
            dataServiceMock.Verify();
            dataServiceMock.Verify(m => m.Update <ProductStock>(
                                       It.IsAny <ProductStock>()),
                                   Times.AtLeastOnce);
            Assert.AreEqual(1, saleExpected.SaleId);
            Assert.AreEqual(1, saleManager.SaleList.Count);
            Assert.AreEqual(2, list.ElementAt(0).Amount);
        }
示例#9
0
        //public JsonResult AddSalesDetails(string ProductCode, int Quantity, int MRP, int TotalMRP)
        public JsonResult AddSales(int CustomerID, string Date, int Loyalitypoint)
        {
            var    sales    = _saleManager.GetAll().ToList();
            var    code     = from s in sales orderby s.Id descending select s.Code;
            string salecode = code.ToString();


            // if (code == null || code == "")
            if (sales.Count() > 0)
            {
                salecode = code.ToString();
                string sub = salecode.Substring(5, 4);
                int    c   = Convert.ToInt32(sub);
                c++;
                string s = c.ToString("0000");
                salecode = "2019-" + s;
            }
            else
            {
                salecode = "2019-0001";
            }

            Sale sale = new Sale();

            sale.CustomerId = CustomerID;
            sale.Date       = Date;


            sale.Code = salecode;

            _saleManager.Add(sale);


            var productList = _saleManager.GetAll().Where(c => c.Code == salecode).ToList();
            var salesId     = from s in productList select(s.Id);


            return(Json(salesId, JsonRequestBehavior.AllowGet));
        }
        static void Main(string[] args)
        {
            MemberManager memberManager1 = new MemberManager(new MernisServiceAdapter());
            Member        member1        = new Member
            {
                FirstName   = "Hamza",
                LastName    = "Kavak",
                DateOfBirth = new DateTime(1998),
                Id          = 1,
                NationalId  = "123456789"
            };

            memberManager1.Save(member1);
            //List<IGameService> games = new List<IGameService>(GameManager1);
            GameManager gameManager1 = new GameManager();
            GameManager gameManager2 = new GameManager();
            Game        game1        = new Game {
                Id = 1, GameName = "Call of Duty", GameType = "War"
            };
            Game game2 = new Game {
                Id = 2, GameName = "Need for Speed", GameType = "Race"
            };


            gameManager1.Add(game1);
            gameManager2.Add(game2);

            CampaignManager campaignManager = new CampaignManager();
            Campaign        campaign        = new Campaign {
                Id = 1, CampaignName = "Kış İndirimi", CampaignType = "%40 a varan indirimler."
            };

            campaignManager.Add(campaign);

            SaleManager saleManager1 = new SaleManager();

            saleManager1.Add(member1, game1, campaign);
        }
示例#11
0
 // POST: api/Sale
 public void Post([FromBody] CreateSale create)
 {
     manager.Add(create);
 }
示例#12
0
        public ActionResult Add(Sale sale, string GrandTotal)
        {
            string message = "";

            double grandtotal = Convert.ToDouble(GrandTotal);

            if (ModelState.IsValid)
            {
                if (_saleManager.Add(sale))
                {
                    message = "Saved";
                    setLoyalty(sale.CustomerId, grandtotal);
                }
                else
                {
                    message = "Not Saved";
                }
            }
            else
            {
                message = "Model State failed";
            }

            ViewBag.Message = message;
            //    //  productViewModel.Products = _productManager.GetAll();
            //    _purchaseViewModel.SupplierSelectListItems = _supplierManager
            //                           .GetAll()
            //                           .Select(c => new SelectListItem()
            //                           {
            //                               Value = c.Id.ToString(),
            //                               Text = c.Name
            //                           }).ToList();

            //    var ProductSelectListItems = _productManager
            //                         .GetAll()
            //                         .Select(c => new SelectListItem()
            //                         {
            //                             Value = c.Id.ToString(),
            //                             Text = c.Name
            //                         }).ToList();
            //    var CategorySelectListItems = _categoryManager
            //                           .GetAll()
            //                           .Select(c => new SelectListItem()
            //                           {
            //                               Value = c.Id.ToString(),
            //                               Text = c.Name
            //                           }).ToList();

            _saleViewModel.CustomerSelectListItems = _customerManager
                                                     .GetAll()
                                                     .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            ViewBag.Customer = _saleViewModel.CustomerSelectListItems;

            _saleViewModel.CategorySelectListItems = _categoryManager
                                                     .GetAll()
                                                     .Select(c => new SelectListItem()
            {
                Value = c.Id.ToString(),
                Text  = c.Name
            }).ToList();

            ViewBag.Category = _saleViewModel.CategorySelectListItems;
            // _saleManager.Add(sale);

            return(View());
        }