예제 #1
0
 public IActionResult ThemPhanCaData(PhanCaView phancaView)//thêm đối tượng xuống database
 {
     ViewBag.Error = "1";
     if (ModelState.IsValid)
     {
         using (var db = new CoffeeShopDbContext())
         {
             var update = (from u in db.bangluong where u.MaNV == phancaView.phancaDTO.MaNV select u).Single();
             if (phancaView.phancaDTO.HeSoLuong == 1)
             {
                 update.Luong += phancaView.phancaDTO.SoGio * 20000;
             }
             else
             {
                 update.Luong += phancaView.phancaDTO.SoGio * 30000;
             }
             db.SaveChanges();
         }
         _phancaServices.themPhanCa(phancaView.phancaDTO);
         ViewBag.Success = "Đã thêm thành công";
         //return Redirect(nameof(ThemPhanCa));
         return(RedirectToAction("Index", "PhanCa"));
     }
     ViewBag.Error = "0";
     return(View(nameof(ThemPhanCa)));
 }
예제 #2
0
        public IActionResult ThemNhanVienData(NhanVienView nhanvienView)//thêm đối tượng xuống database
        {
            ViewBag.Error = "1";
            if (ModelState.IsValid)
            {
                using (var db = new CoffeeShopDbContext())
                {
                    var luong = new BangLuong
                    {
                        MaNV       = nhanvienView.nhanvienDTO.MaNV.ToString(),
                        TienThuong = 0,
                        TamUng     = 0,
                        Luong      = 0
                    };
                    db.bangluong.Add(luong);
                    db.SaveChanges();
                }

                _nhanvienServices.themNhanVien(nhanvienView.nhanvienDTO);
                ViewBag.Success = "Đã thêm thành công";
                //return Redirect(nameof(ThemNhanVien));
                return(RedirectToAction("Index", "NhanVien"));
            }
            ViewBag.Error = "0";
            return(View(nameof(ThemNhanVien)));
        }
예제 #3
0
 public IActionResult Index()
 {
     using (var db = new CoffeeShopDbContext())
     {
         var thongke = (from u in db.menu select u).Single();
         int x;
         new ThongKeView()
         {
             TenMon  = thongke.TenMon,
             SoLuong = 100 - thongke.SoLuongTon
         };
     };
     return(View());
 }
예제 #4
0
 public IActionResult Index()
 {
     // if (HttpContext.Session.GetString("123") == null)
     //    return RedirectToAction("Login", "Admin");
     // else
     // {
     using (var db = new CoffeeShopDbContext())
     {
         ViewBag.Product = new HomeView()
         {
             soluong  = db.hoadon.Count(),
             tongtien = db.cthd.Sum(cthd => cthd.Gia)
         };
     };
     return(View());
     //}
 }
예제 #5
0
 public IActionResult ThemChiTietNhapData(ChiTietNhapView chitietnhapView)//thêm đối tượng xuống database
 {
     ViewBag.Error = "1";
     if (ModelState.IsValid)
     {
         using (var db = new CoffeeShopDbContext())
         {
             var update = (from u in db.menu where u.MaMon == chitietnhapView.chitietnhapDTO.MaMon select u).Single();
             update.SoLuongTon += chitietnhapView.chitietnhapDTO.SoLuong;
             db.SaveChanges();
         }
         _chitietnhapServices.themChiTietNhap(chitietnhapView.chitietnhapDTO);
         ViewBag.Success = "Đã thêm thành công";
         //return Redirect(nameof(ThemChiTietNhap));
         return(RedirectToAction("Index", "ChiTietNhap"));
     }
     ViewBag.Error = "0";
     return(View(nameof(ThemChiTietNhap)));
 }
예제 #6
0
        public IActionResult Login(string userName, string password)
        {
            if (!string.IsNullOrEmpty(userName) && string.IsNullOrEmpty(password))
            {
                return(RedirectToAction("Login"));
            }

            bool isAuthenticated = false;

            if (userName == "admin" && password == "chinhnd719")
            {
                // isAuthenticated = true;
                //HttpContext.Session.SetString("123", "abc");
                //return RedirectToAction("Index", "Home");


                isAuthenticated = true;
            }
            else
            {
                using (var db = new CoffeeShopDbContext())
                {
                    var update = (from u in db.taikhoan where u.UserName == userName select u).Single();
                    if (update.PassWord == password)
                    {
                        isAuthenticated = true;
                    }
                }
            }

            if (isAuthenticated)
            {
                //var principal = new ClaimsPrincipal(identity);

                //var login = HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal);

                return(RedirectToAction("Index", "Home"));
            }
            return(View());
        }
예제 #7
0
        public void CoffeeExists()
        {
            DbContextOptions <CoffeeShopDbContext> options = new DbContextOptionsBuilder <CoffeeShopDbContext>().UseInMemoryDatabase("CanCreateCoffee").Options;

            using (CoffeeShopDbContext context = new CoffeeShopDbContext(options))
            {
                Coffee coffee = new Coffee();
                coffee.ID          = 1;
                coffee.Name        = "latte";
                coffee.Price       = 2;
                coffee.Description = "tasty";
                coffee.URL         = "www.coffee.com";

                CoffeeManager coffeeManager = new CoffeeManager(context);

                coffeeManager.CoffeeExists(1);

                var result = context.Coffee.Any(c => c.ID == 1);

                Assert.False(result);
            }
        }
예제 #8
0
        public async void CanCreateCoffee()
        {
            DbContextOptions <CoffeeShopDbContext> options = new DbContextOptionsBuilder <CoffeeShopDbContext>().UseInMemoryDatabase("CanCreateCoffee").Options;

            using (CoffeeShopDbContext context = new CoffeeShopDbContext(options))
            {
                Coffee coffee = new Coffee();
                coffee.ID          = 1;
                coffee.Name        = "latte";
                coffee.Price       = 2;
                coffee.Description = "tasty";
                coffee.URL         = "www.coffee.com";

                CoffeeManager coffeeManager = new CoffeeManager(context);

                await coffeeManager.CreateCoffee(coffee);

                var result = context.Coffee.FirstOrDefault(c => c.ID == coffee.ID);

                Assert.Equal(coffee, result);
            }
        }
예제 #9
0
 public OrderService(CoffeeShopDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #10
0
 public CoffeeManager(CoffeeShopDbContext context)
 {
     _context = context;
 }
예제 #11
0
 public ShipperDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #12
0
 public ProductService(CoffeeShopDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #13
0
 public EmployeeDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #14
0
 public ProductDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #15
0
 public NewsDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #16
0
 public ShopController(CoffeeShopDbContext context)
 {
     this._context      = context;
     this.AvalableItems = _context.Items.ToList();
 }
예제 #17
0
 public EventDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #18
0
 public CategoryDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #19
0
 public MenusController(CoffeeShopDbContext coffeeShopDbContext)
 {
     _coffeeShopDbContext = coffeeShopDbContext;
 }
예제 #20
0
 /// <summary>
 /// Prevents a default instance of the <see cref="ShoppingCart"/> class from being created.
 /// </summary>
 /// <param name="context">The context<see cref="CoffeeShopDbContext"/></param>
 private ShoppingCart(CoffeeShopDbContext context)
 {
     _context = context;
 }
예제 #21
0
 public EmployeeService(CoffeeShopDbContext dbContext)
 {
     this.dbContext = dbContext;
 }
예제 #22
0
 public OrderManager(CoffeeShopDbContext context, ShoppingCart shoppingCart)
 {
     _context      = context;
     _shoppingCart = shoppingCart;
 }
 //controller
 public CoffeeShopController(CoffeeShopDbContext context)
 {
     _context = context;
 }
예제 #24
0
 public ReservationsController(CoffeeShopDbContext coffeeShopDbContext)
 {
     _coffeeShopDbContext = coffeeShopDbContext;
 }
예제 #25
0
 public OrderDetailDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #26
0
 private readonly CoffeeShopDbContext _conText;          //Khởi tạo biến context
 public BangLuongRepository(CoffeeShopDbContext conText) //contructor để gán giá trị database cho biến context
 {
     this._conText = conText;
 }
예제 #27
0
 public BillDetailDao()
 {
     db = new CoffeeShopDbContext();
 }
예제 #28
0
 public DatabaseController(CoffeeShopDbContext context)
 {
     _context = context;
 }
예제 #29
0
 private readonly CoffeeShopDbContext _conText;            //Khởi tạo biến context
 public ChiTietNhapRepository(CoffeeShopDbContext conText) //contructor để gán giá trị database cho biến context
 {
     this._conText = conText;
 }
예제 #30
0
 public CustomerDao()
 {
     db = new CoffeeShopDbContext();
 }