コード例 #1
0
        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";
        }
コード例 #2
0
        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();
        }
コード例 #3
0
        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";
        }
コード例 #4
0
        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();
        }
コード例 #5
0
 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;
     }
 }
コード例 #6
0
ファイル: PCService.cs プロジェクト: AnTTSE61258/NetCafeWeb
 public NetCafe GetNetCafeByID(int NetCafeID)
 {
     IRepository<NetCafe> repository = new NetCafeRepository();
     if (NetCafeID.ToString() == null)
     {
         return null;
     }
     else
     {
         NetCafe net = repository.findById(NetCafeID);
         return net;
     }
 }