Exemple #1
0
        public ViewResult Index()
        {
            IEnumerable <Camera_Backup> camera_backup = null;

            using (var client = new HttpClient())
            {
                client.BaseAddress = new Uri("https://localhost:44327/api/");
                var respornseTask = client.GetAsync("Camera_Backup");
                respornseTask.Wait();

                var result = respornseTask.Result;
                if (result.IsSuccessStatusCode)
                {
                    var m = result.Content.ReadAsAsync <List <Camera_Backup> >();
                    m.Wait();
                    camera_backup = m.Result;
                }
                else
                {
                    camera_backup = Enumerable.Empty <Camera_Backup>();
                    ModelState.AddModelError(string.Empty, "Server error. Please contract admin for help");
                }
            }

            Thongtin thongtin = new Thongtin();

            thongtin.Camera_Backup = camera_backup;
            return(View(thongtin));
        }
        public ActionResult DeleteConfirmed(int id)
        {
            Thongtin thongtin = db.thongtin.Find(id);

            db.thongtin.Remove(thongtin);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Name,Class,Faculty,PhoneNumber")] Thongtin thongtin)
 {
     if (ModelState.IsValid)
     {
         db.Entry(thongtin).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(thongtin));
 }
        public ActionResult Create([Bind(Include = "ID,Name,Class,Faculty,PhoneNumber")] Thongtin thongtin)
        {
            if (ModelState.IsValid)
            {
                db.thongtin.Add(thongtin);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(thongtin));
        }
        // GET: Thongtins/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Thongtin thongtin = db.thongtin.Find(id);

            if (thongtin == null)
            {
                return(HttpNotFound());
            }
            return(View(thongtin));
        }