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))); }
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))); }
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()); }
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()); //} }
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))); }
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()); }
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); } }
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); } }
public OrderService(CoffeeShopDbContext dbContext) { this.dbContext = dbContext; }
public CoffeeManager(CoffeeShopDbContext context) { _context = context; }
public ShipperDao() { db = new CoffeeShopDbContext(); }
public ProductService(CoffeeShopDbContext dbContext) { this.dbContext = dbContext; }
public EmployeeDao() { db = new CoffeeShopDbContext(); }
public ProductDao() { db = new CoffeeShopDbContext(); }
public NewsDao() { db = new CoffeeShopDbContext(); }
public ShopController(CoffeeShopDbContext context) { this._context = context; this.AvalableItems = _context.Items.ToList(); }
public EventDao() { db = new CoffeeShopDbContext(); }
public CategoryDao() { db = new CoffeeShopDbContext(); }
public MenusController(CoffeeShopDbContext coffeeShopDbContext) { _coffeeShopDbContext = coffeeShopDbContext; }
/// <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; }
public EmployeeService(CoffeeShopDbContext dbContext) { this.dbContext = dbContext; }
public OrderManager(CoffeeShopDbContext context, ShoppingCart shoppingCart) { _context = context; _shoppingCart = shoppingCart; }
//controller public CoffeeShopController(CoffeeShopDbContext context) { _context = context; }
public ReservationsController(CoffeeShopDbContext coffeeShopDbContext) { _coffeeShopDbContext = coffeeShopDbContext; }
public OrderDetailDao() { db = new CoffeeShopDbContext(); }
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; }
public BillDetailDao() { db = new CoffeeShopDbContext(); }
public DatabaseController(CoffeeShopDbContext context) { _context = context; }
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; }
public CustomerDao() { db = new CoffeeShopDbContext(); }