Ejemplo n.º 1
0
        //[ValidateAntiForgeryToken]
        public IActionResult FinishPizza(PizzaViewModel pModel)
        {
            //if (ModelState.IsValid)
            //{
            //  return Redirect("user/home");
            //}

            OrderRepository   oRepo = new OrderRepository(_db);
            PizzaRepository   pRepo = new PizzaRepository(_db);
            CrustRepository   cRepo = new CrustRepository(_db);
            SizeRepository    sRepo = new SizeRepository(_db);
            ToppingRepository tRepo = new ToppingRepository(_db);
            PizzaFactory      pf    = new PizzaFactory();
            Pizza             p     = pf.CreateCustom();

            p.Crust = cRepo.GetCrustByName(pModel.Crust);
            p.Size  = sRepo.GetSizeByName(pModel.Size);
            p.Order = oRepo.Get2(pModel.OrderId);
            foreach (SelectedTopping st in pModel.SelectedToppings)
            {
                if (st.IsSelected)
                {
                    p.PizzaToppings.Add(new PizzaTopping()
                    {
                        Topping = tRepo.GetToppingByName(st.Name), Pizza = p
                    });
                }
            }
            p.Price = p.GetPrice();
            pRepo.Add(p);
            pModel.Order = oRepo.Get(pModel.OrderId);
            return(View("Order", pModel));
        }
Ejemplo n.º 2
0
        public HttpResponseMessage PostSize([FromBody] int id)
        {
            var size = SizeRepository.GetSize(id);
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, size);

            return(response);
        }
Ejemplo n.º 3
0
        public void SetUp()
        {
            var database = new Mock <IDatabase>();

            database.Setup(x => x.Query <SizeRecord>()).Returns(new List <SizeRecord>
            {
                new SizeRecord
                {
                    Id   = 1,
                    Name = "Small"
                },
                new SizeRecord
                {
                    Id   = 2,
                    Name = "Medium"
                },
                new SizeRecord
                {
                    Id   = 3,
                    Name = "Large"
                }
            });

            var subject = new SizeRepository(database.Object);

            _result = subject.GetAll();
        }
Ejemplo n.º 4
0
        public bool Save(Size size, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  si     = SizeRepository.GetQueryable().FirstOrDefault(s => s.ID == size.ID);

            if (si != null)
            {
                try
                {
                    si.SizeName = size.SizeName;
                    si.SizeNo   = size.SizeNo;
                    si.Length   = size.Length;
                    si.Width    = size.Width;
                    si.Height   = size.Height;

                    SizeRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            else
            {
                strResult = "原因:未找到当前需要修改的数据!";
            }
            return(result);
        }
Ejemplo n.º 5
0
        public HttpResponseMessage GetSizes()
        {
            var size = SizeRepository.GetAllSizes();
            HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, size);

            return(response);
        }
Ejemplo n.º 6
0
        public bool Delete(int sizeId, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  si     = SizeRepository.GetQueryable().FirstOrDefault(s => s.ID == sizeId);

            if (si != null)
            {
                try
                {
                    SizeRepository.Delete(si);
                    SizeRepository.SaveChanges();
                    result = true;
                }
                catch (Exception)
                {
                    strResult = "原因:已在使用";
                }
            }
            else
            {
                strResult = "原因:未找到当前需要删除的数据!";
            }
            return(result);
        }
Ejemplo n.º 7
0
        public bool Add(Size size, out string strResult)
        {
            strResult = string.Empty;
            bool result = false;
            var  si     = new Size();

            if (si != null)
            {
                try
                {
                    si.SizeName = size.SizeName;
                    si.SizeNo   = size.SizeNo;
                    si.Length   = size.Length;
                    si.Width    = size.Width;
                    si.Height   = size.Height;

                    SizeRepository.Add(si);
                    SizeRepository.SaveChanges();
                    result = true;
                }
                catch (Exception ex)
                {
                    strResult = "原因:" + ex.Message;
                }
            }
            else
            {
                strResult = "原因:找不到当前登陆用户!请重新登陆!";
            }
            return(result);
        }
Ejemplo n.º 8
0
        public async Task TestGetSizes()
        {
            var sizeRepository = new SizeRepository(mockContext.Object);
            var sizeCount      = await sizeRepository.GetAll();

            Assert.AreEqual(4, sizeCount.Count());
        }
Ejemplo n.º 9
0
        public List <Size> GetSize(
            IUnitOfWork uow,
            SizeType sizeType          = null,
            bool onlyUseInEmployee     = false,
            bool onlyUseInNomenclature = false)
        {
            if (sizes is null)
            {
                sizes = SizeRepository.GetSize(uow);
            }
            var filterSizes = (IEnumerable <Size>)sizes;

            if (sizeType != null)
            {
                filterSizes = filterSizes.Where(x => x.SizeType == sizeType);
            }
            if (onlyUseInEmployee)
            {
                filterSizes = filterSizes.Where(x => x.UseInEmployee);
            }
            if (onlyUseInNomenclature)
            {
                filterSizes = filterSizes.Where(x => x.UseInNomenclature);
            }
            return(filterSizes.ToList());
        }
Ejemplo n.º 10
0
        public ActionResult Create(Size model)
        {
            //model.OrganizationId = OrganizationId;
            //model.CreatedDate = System.DateTime.Now;
            //model.CreatedBy = UserID.ToString();

            var repo = new SizeRepository();
            //bool isexists = repo.IsFieldExists(repo.ConnectionString(), "Size", "SizeName", model.SizeName, null, null);
            //if (!isexists)
            //{
            var result = new SizeRepository().InsertSize(model);

            if (result.SizeCode > 0)
            {
                TempData["Success"]      = "Added Successfully!";
                TempData["SizeUserCode"] = result.SizeUserCode;
                return(RedirectToAction("Create"));
            }

            else
            {
                TempData["error"]        = "Oops!!..Something Went Wrong!!";
                TempData["SizeUserCode"] = null;
                return(View("Create", model));
            }
        }
Ejemplo n.º 11
0
        public async Task TestGetSpecifiedSize()
        {
            var sizeRepository = new SizeRepository(mockContext.Object);
            var foundSize      = await sizeRepository.GetById(searchedSize.Id);

            Assert.AreEqual(searchedSize, foundSize);
        }
Ejemplo n.º 12
0
        public object GetSize(int page, int rows, string queryString, string value)
        {
            string id = "", sizeName = "";

            if (queryString == "id")
            {
                id = value;
            }
            else
            {
                sizeName = value;
            }
            IQueryable <Size> sizeQuery = SizeRepository.GetQueryable();
            //int Id = Convert.ToInt32(id);
            var size = sizeQuery.Where(si => si.SizeName.Contains(sizeName))
                       .OrderBy(si => si.ID).AsEnumerable().
                       Select(si => new
            {
                si.ID,
                si.SizeName,
                si.SizeNo
            });
            int total = size.Count();

            size = size.Skip((page - 1) * rows).Take(rows);
            return(new { total, rows = size.ToArray() });
        }
Ejemplo n.º 13
0
        public object GetDetails(int page, int rows, Size size)
        {
            IQueryable <Size> sizeQuery = SizeRepository.GetQueryable();
            var SizeDetail = sizeQuery.Where(s => s.SizeName.Contains(size.SizeName)).OrderBy(s => s.ID);

            var SizeDetail1 = SizeDetail;

            if (size.SizeNo != null && size.SizeNo != 0)
            {
                SizeDetail1 = SizeDetail.Where(s => s.SizeNo == size.SizeNo).OrderBy(s => s.ID);
            }

            int total      = SizeDetail.Count();
            var sRMDetails = SizeDetail1.Skip((page - 1) * rows).Take(rows);
            var sRM_Detail = sRMDetails.ToArray().Select(s => new
            {
                s.ID,
                s.SizeName,
                s.Length,
                s.SizeNo,
                s.Width,
                s.Height
            });

            return(new { total, rows = sRM_Detail.ToArray() });
        }
Ejemplo n.º 14
0
        public static async Task <bool> CheckIfSizeExists(size.SizeId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);

            return(await repository.ExistsAsync(id));
        }
 private SizeSingleton()
 {
     repository = new SizeRepository(DbContextSingleton.Instance.Context);
     Sizes      = repository.GetList();
     _sizes.Add(typeof(SmallSize), new SmallSize());
     _sizes.Add(typeof(MediumSize), new MediumSize());
     _sizes.Add(typeof(LargeSize), new LargeSize());
 }
Ejemplo n.º 16
0
        public void SetUp()
        {
            var database = new Mock <IDatabase>();

            database.Setup(x => x.Query <SizeRecord>()).Throws <Exception>();

            var subject = new SizeRepository(database.Object);

            _result = subject.GetAll();
        }
Ejemplo n.º 17
0
        public async Task Size_inserted_to_database()
        {
            Size size = await CreateValidSize();

            var repository = new SizeRepository(fixture.context);
            var sut        = await repository.LoadAsync(size.Id);

            Assert.True(await repository.ExistsAsync(sut.Id));
            Assert.NotEmpty(sut.Amount);
        }
Ejemplo n.º 18
0
 public UnitOfWork(PizzaBoxContext context)
 {
     _context  = context;
     Stores    = new StoreRepository(context);
     Customers = new CustomerRepository(context);
     Crusts    = new CrustRepository(context);
     Sizes     = new SizeRepository(context);
     Toppings  = new ToppingRepository(context);
     Pizzas    = new PizzaRepository(context);
     Orders    = new OrderRepository(context);
 }
Ejemplo n.º 19
0
 public PizzeriaService(PizzaBoxDbContext context)
 {
     _ctx = context;
     _pr  = new PizzaRepository(context);
     _cr  = new CrustRepository(context);
     _sr  = new SizeRepository(context);
     _tr  = new ToppingRepository(context);
     _ur  = new UserRepository(context);
     _or  = new OrderRepository(context);
     _rr  = new StoreRepository(context);
 }
Ejemplo n.º 20
0
        public UnitOfWork(IDataContext context)
        {
            _context = context;

            OrderRepository            = new OrderRepository(_context);
            ProductRepository          = new ProductRepository(_context);
            SizeRepository             = new SizeRepository(_context);
            VatRateRepository          = new VatRateRepository(_context);
            OrderProductLinkRepository = new OrderProductLinkRepository(_context);
            CategoryRepository         = new CategoryRepository(_context);
        }
Ejemplo n.º 21
0
        public bool Save(Size size)
        {
            var si = SizeRepository.GetQueryable().FirstOrDefault(s => s.ID == size.ID);

            si.ID       = size.ID;
            si.Height   = size.Height;
            si.Length   = size.Length;
            si.Width    = size.Width;
            si.SizeNo   = size.SizeNo;
            si.SizeName = size.SizeName;
            SizeRepository.SaveChanges();
            return(true);
        }
Ejemplo n.º 22
0
        public void ConvertSpecial(PizzaViewModel pizzaViewModel, PizzaStoreDBContext _db)
        {
            var CR            = new CrustRepository(_db);
            var SR            = new SizeRepository(_db);
            var PR            = new PizzaRepository(_db);
            var TR            = new ToppingRepository(_db);
            var OR            = new OrderRepository(_db);
            var UR            = new UserRepository(_db);
            var STR           = new StoreRepository(_db);
            var PF            = new PizzaFactory();
            var tempSpecialty = PF.Create();

            tempSpecialty = PR.Get(SelectedPizza);
            var tempPizza = PF.Create();

            tempPizza.Name         = SelectedPizza;
            tempPizza.Description  = tempSpecialty.Description;
            tempPizza.Size         = SR.Get(pizzaViewModel.Size);
            tempPizza.Crust        = CR.Get(pizzaViewModel.Crust);
            tempPizza.Toppings     = new List <ToppingsModel>();
            tempPizza.SpecialPizza = true;

            foreach (var t in tempSpecialty.Toppings)
            {
                var tempTopping = new ToppingsModel()
                {
                    Name = t.Name, Description = t.Description
                };
                tempPizza.Toppings.Add(tempTopping);
                TR.Add(tempTopping);
            }

            var cart = OR.GetCurrentOrder();
            var OF   = new OrderFactory();

            if (cart != null)
            {
                OR.AddPizza(cart.Id, tempPizza);
            }
            else
            {
                cart = OF.Create();
                cart.Pizzas.Add(tempPizza);
                cart.CurrentOrder = true;
                OR.UpdateCurrentOrder(cart);
                var tempUser = UR.Get(User);
                UR.AddOrder(tempUser.Id, cart);
                var tempStore = STR.Get(Store);
                STR.AddOrder(tempStore.Id, cart);
            }
        }
Ejemplo n.º 23
0
        public bool Add(Size size)
        {
            var s = new Size();

            s.ID       = size.ID;
            s.Height   = size.Height;
            s.Length   = size.Length;
            s.SizeName = size.SizeName;
            s.SizeNo   = size.SizeNo;
            s.Width    = size.Width;
            SizeRepository.Add(s);
            SizeRepository.SaveChanges();
            return(true);
        }
Ejemplo n.º 24
0
        public bool Delete(int sizeId)
        {
            var size = SizeRepository.GetQueryable().FirstOrDefault(s => s.ID == sizeId);

            if (size != null)
            {
                SizeRepository.Delete(size);
                SizeRepository.SaveChanges();
            }
            else
            {
                return(false);
            }
            return(true);
        }
Ejemplo n.º 25
0
        public static async Task RemoveSize(size.SizeId id)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new size.SizeService(repository, unitOfWork);
            var sizeController   = new SizeController(service);

            var updateCommand = new size.Commands.DeleteSize
            {
                Id = id
            };

            await sizeController.DeleteSize(updateCommand);
        }
Ejemplo n.º 26
0
        public IList <SizeType> GetSizeType(
            IUnitOfWork uow,
            bool onlyUseInEmployee = false)
        {
            if (types is null)
            {
                types = SizeRepository.GetSizeType(uow);
            }
            var filterTypes = types;

            if (onlyUseInEmployee)
            {
                return(filterTypes.Where(x => x.UseInEmployee).ToList());
            }
            return(filterTypes);
        }
Ejemplo n.º 27
0
        public static async Task UpdateSizeAmount(size.SizeId id, string amount)
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new size.SizeService(repository, unitOfWork);
            var sizeController   = new SizeController(service);

            var updateCommand = new size.Commands.SetSizeAmount
            {
                Id     = id,
                Amount = amount
            };

            await sizeController.Put(updateCommand);
        }
Ejemplo n.º 28
0
        public static async Task <dynamic> CreateInvalidSize()
        {
            var connectionString = ConnectivityService.GetConnectionString("TEMP");
            var context          = new SplurgeStopDbContext(connectionString);
            var repository       = new SizeRepository(context);
            var unitOfWork       = new EfCoreUnitOfWork(context);
            var service          = new size.SizeService(repository, unitOfWork);

            var command = new size.Commands.Create
            {
                Id = null
            };

            var sizeController = new SizeController(service);

            return(await sizeController.Post(command));
        }
Ejemplo n.º 29
0
        public PizzaViewModel(PizzaStoreDBContext dbo)
        {
            var cRepo = new CrustRepository(dbo);

            Crusts = cRepo.GetAll();
            var sRepo = new SizeRepository(dbo);

            Sizes = sRepo.GetAll();
            var tRepo = new ToppingRepository(dbo);

            Toppings  = new List <ToppingsModel>();
            Toppings2 = new List <CheckBoxTopping>();
            foreach (ToppingsModel t in tRepo.GetAll())
            {
                Toppings.Add(t);
            }
            foreach (var t in Toppings)
            {
                Toppings2.Add(new CheckBoxTopping()
                {
                    Name = t.Name, Id = t.Id, Description = t.Description, Text = t.Name, IsSelected = false
                });
            }
            var uRepo = new UserRepository(dbo);

            Users = uRepo.GetAll();
            var stRepo = new StoreRepository(dbo);

            Stores = stRepo.GetAll();
            var pRepo = new PizzaRepository(dbo);

            SpecialtyPizzas = pRepo.GetAllSpecialty();
            Pizzas          = new List <CheckBoxPizza>();
            GetCart(dbo);
            if (Cart.Pizzas != null)
            {
                foreach (PizzaModel p in Cart.Pizzas)
                {
                    Pizzas.Add(new CheckBoxPizza()
                    {
                        Name = p.Name, Id = p.Id, Description = p.Description, Text = p.Name, IsSelected = false
                    });
                }
            }
        }
Ejemplo n.º 30
0
 public UnitOfWork(CorpCommDbContext db)
 {
     _db          = db;
     Brand        = new BrandRepository(_db);
     StationType  = new StationTypeRepository(_db);
     Unit         = new UnitRepository(_db);
     Department   = new DepartmentRepository(_db);
     Status       = new StatusRepository(_db);
     Size         = new SizeRepository(_db);
     Email        = new EmailRepository(_db);
     Location     = new LocationRepository(_db);
     Event        = new EventRepository(_db);
     Station      = new StationRepository(_db);
     Collateral   = new CollateralRepository(_db);
     OrderDetails = new OrderDetailsRepository(_db);
     OrderHeader  = new OrderHeaderRepository(_db);
     ShoppingCart = new ShoppingCartRepository(_db);
     History      = new HistoryRepository(_db);
     SP_Call      = new SP_Call(_db);
 }