public String deactivate() { String idParam = Request.Params["id"]; int id = int.Parse(idParam); IRepository<NetCafe> repository = new NetCafeRepository(); NetCafe deactivateNet = repository.findById(id); if (deactivateNet == null) { return "false"; } if (deactivateNet.NetCafeStatus == SLIM_CONFIG.NETCAFE_ACTIVE) { deactivateNet.NetCafeStatus = SLIM_CONFIG.NETCAFE_DEACTIVE; } repository.Update(deactivateNet); return "true"; }
public String add() { String name = Request.Params["name"]; String address = Request.Params["address"]; String supervisor = Request.Params["supervisor"]; String status = Request.Params["status"]; String phoneNumber = Request.Params["phoneNumber"]; String description = Request.Params["description"]; double locationX = Double.Parse(Request.Params["locationX"]); double locationY = Double.Parse(Request.Params["locationY"]); //valid du lieu NetCafeService netcafeService = new NetCafeService(); if (netcafeService.isExistWithName(name)) { return "Net cafe with this name is existed!"; } // Check supervisor da quan ly net nao hay chua else if (netcafeService.isExistWithSupervisor(int.Parse(supervisor))) { return "This supervisor has been managed a Netcafe already!"; } IRepository<NetCafe> repository = new NetCafeRepository(); NetCafe netcafe = new NetCafe(); netcafe.NetCafeName = name; netcafe.NetCafeAddress = address; netcafe.SupervisorID = int.Parse(supervisor); netcafe.NetCafeStatus = int.Parse(status); netcafe.NetCafePhoneNumber = phoneNumber; netcafe.NetCafeDescriptions = description; netcafe.LocationX = locationX; netcafe.LocationY = locationY; repository.Add(netcafe); return "true"; }
public ActionResult Create(int? id) { //Lay login user name String username = User.Identity.GetUserName(); UserRepository userRepo = new UserRepository(); int userId = userRepo.getIDByUsername(username); ViewBag.userId = userId; //Lay user id IRepository<NetCafe> repository = new NetCafeRepository(); if (id != null) { PCRepository repo = new PCRepository(); List<PC> pcs = repo.findAvailable(id.Value); NetCafe selectedNetcafe = repository.findById(id.Value); ViewBag.selectedNetCafe = selectedNetcafe; ViewBag.pcs = pcs; } IEnumerable<NetCafe> iNetCafes = repository.List; List<NetCafe> netcafes = iNetCafes.Cast<NetCafe>().ToList(); ViewBag.netcafes = netcafes; return View(); }
public ActionResult Index() { var store = new Microsoft.AspNet.Identity.EntityFramework.UserStore<NetCafeWeb.Models.ApplicationUser>(new NetCafeWeb.Models.ApplicationDbContext()); var manager = new Microsoft.AspNet.Identity.UserManager<NetCafeWeb.Models.ApplicationUser>(store); var a = manager.IsInRoleAsync(User.Identity.GetUserId(), "Admin"); bool isAdmin = a.Result; IRepository<User> userRepository = new UserRepository(); IEnumerable<User> users = userRepository.List; ViewBag.users = users.Cast<User>().ToList(); IRepository<PC> pcRepository = new PCRepository(); IEnumerable<PC> pcs = pcRepository.List; ViewBag.pcs = pcs.Cast<PC>().ToList(); if (isAdmin) { //show het order IRepository<Order> repository = new OrderRepository(); IEnumerable<Order> order = repository.List; ViewBag.orders = order.Cast<Order>().ToList(); //FormsAuthentication.SetAuthCookie("asd", false); return View(); } else //La supervisor { //Lay supervior user String supervisorName = User.Identity.Name; //Lay supervior id UserRepository repo = new UserRepository(); NetCafeRepository netRepo = new NetCafeRepository(); OrderRepository orderRepo = new OrderRepository(); int supervisorId = repo.getIDByUsername(supervisorName); //Lay netcafe id int netID = netRepo.getNetCafeIDByName(supervisorId); //hien thi order cua netcafe id List<Order> orders = orderRepo.getOrderByNetCafe(netID); ViewBag.orders = orders; } return View(); }
public List<NetCafe> getAllNetCafe() { IRepository<NetCafe> repository = new NetCafeRepository(); IEnumerable<NetCafe> netcafes = repository.List; return netcafes.Cast<NetCafe>().ToList(); }
public String editNetCafe() { String idParam = Request.Params["id"]; String name = Request.Params["name"]; String address = Request.Params["address"]; String supervisor = Request.Params["supervisor"]; String status = Request.Params["status"]; String phoneNumber = Request.Params["phoneNumber"]; String description = Request.Params["description"]; IRepository<NetCafe> repository = new NetCafeRepository(); int id = int.Parse(idParam); NetCafe netcafe = repository.findById(id); netcafe.NetCafeName = name; netcafe.NetCafeAddress = address; netcafe.SupervisorID = int.Parse(supervisor); netcafe.NetCafeStatus = int.Parse(status); netcafe.NetCafePhoneNumber = phoneNumber; netcafe.NetCafeDescriptions = description; // kiem tra xem noi dung edit co hop le hay khong NetCafeService netcafeService = new NetCafeService(); if (!netcafeService.checkValidEdition(netcafe)) { return "false"; } repository.Update(netcafe); return "true"; }
public ActionResult edit(int? id) { if (id == null) { return RedirectToAction("Index", "NetCafe"); } else { IRepository<NetCafe> repository = new NetCafeRepository(); NetCafe netcafe = repository.findById(id.Value); ViewBag.netcafe = netcafe; UserRepository repository2 = new UserRepository(); ViewBag.supervisors = repository2.supervisorList(); } return View(); }
// GET: NetCafe public ActionResult Index() { IRepository<NetCafe> repository = new NetCafeRepository(); IEnumerable<NetCafe> netCafes = repository.List; ViewBag.netcafes = netCafes.Cast<NetCafe>().ToList(); UserRepository repository2 = new UserRepository(); ViewBag.supervisors = repository2.supervisorList(); return View(); }
public NetCafe getNetCafe() { String idParam = Request.Params["id"]; int id = int.Parse(idParam); IRepository<NetCafe> repository = new NetCafeRepository(); NetCafe netCafe = repository.findById(id); if (netCafe == null) { return netCafe; } else { return null; } }
public List<NetCafe> GetNetList() { NetCafeRepository NetRepo = new NetCafeRepository(); List<NetCafe> NetList = new List<NetCafe>(); NetList = NetRepo.GetAvailableNetList(); return NetList; }
public NetCafe GetNetCafeByID(int NetCafeID) { IRepository<NetCafe> repository = new NetCafeRepository(); if (NetCafeID.ToString() == null) { return null; } else { NetCafe net = repository.findById(NetCafeID); return net; } }
public List<NetCafe> GetManageNet(string username) { NetCafeRepository NetRepo = new NetCafeRepository(); UserRepository UserRepo = new UserRepository(); List<NetCafe> ManageNet = new List<NetCafe>(); int SuperID = UserRepo.getIDByUsername(username); if (SuperID.ToString() == null) { return null; } else { try { ManageNet = NetRepo.findBySuID(SuperID); } catch (Exception e) { e.GetHashCode(); return null; } return ManageNet; } }