Exemple #1
0
        public JsonResult ShowSo(int id)
        {
            HeThongSoViewModels hs = new HeThongSoViewModels();

            hs.ManHinhID = id;
            var       xp        = Mapper.Map <HeThongSoViewModels, HeThongSo>(hs);
            HeThongSo heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID && !x.Goi).OrderBy(x => x.STT).FirstOrDefault();

            if (heThongSo == null)
            {
                heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID).OrderByDescending(x => x.STT).FirstOrDefault();
            }
            else
            {
                heThongSo.Goi             = true;
                db.Entry(heThongSo).State = EntityState.Modified;
                db.SaveChanges();
                heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID && !x.Goi).OrderBy(x => x.STT).FirstOrDefault();
            }
            if (heThongSo == null)
            {
                heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID).OrderByDescending(x => x.STT).FirstOrDefault();
            }
            return(Json(heThongSo, JsonRequestBehavior.AllowGet));
        }
Exemple #2
0
        public async Task <IHttpActionResult> PutHeThongSo(int id, HeThongSo heThongSo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != heThongSo.ID)
            {
                return(BadRequest());
            }

            db.Entry(heThongSo).State = EntityState.Modified;

            try
            {
                await db.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!HeThongSoExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Exemple #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            HeThongSo heThongSo = db.HeThongSos.Find(id);

            db.HeThongSos.Remove(heThongSo);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Exemple #4
0
        public HeThongSo GetAllStocks(int id)
        {
            HeThongSoViewModels hs = new HeThongSoViewModels();

            hs.ManHinhID = id;
            var       xp        = Mapper.Map <HeThongSoViewModels, HeThongSo>(hs);
            HeThongSo heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID && !x.Goi).OrderBy(x => x.STT).FirstOrDefault();

            return(heThongSo);
        }
Exemple #5
0
 public ActionResult Edit([Bind(Include = "ID,STT,Goi,DateCreated,ManHinhID")] HeThongSo heThongSo)
 {
     ViewBag.ManHinh = db.ManHinhs.ToList();
     if (ModelState.IsValid)
     {
         db.Entry(heThongSo).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(heThongSo));
 }
Exemple #6
0
        public async Task <IHttpActionResult> GetHeThongSo(int id)
        {
            HeThongSo heThongSo = await db.HeThongSos.FindAsync(id);

            if (heThongSo == null)
            {
                return(NotFound());
            }

            return(Ok(heThongSo));
        }
Exemple #7
0
        public async Task <IHttpActionResult> PostHeThongSo(HeThongSo heThongSo)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.HeThongSos.Add(heThongSo);
            await db.SaveChangesAsync();

            return(CreatedAtRoute("DefaultApi", new { id = heThongSo.ID }, heThongSo));
        }
Exemple #8
0
        // GET: HeThongSoes/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HeThongSo heThongSo = db.HeThongSos.Find(id);

            if (heThongSo == null)
            {
                return(HttpNotFound());
            }
            return(View(heThongSo));
        }
Exemple #9
0
        // GET: HeThongSoes/Details/5
        public ActionResult ViewDetails(int id)
        {
            HeThongSoViewModels hs = new HeThongSoViewModels();

            hs.ManHinhID = id;
            var       xp        = Mapper.Map <HeThongSoViewModels, HeThongSo>(hs);
            HeThongSo heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID && !x.Goi).OrderBy(x => x.STT).FirstOrDefault();

            if (heThongSo == null)
            {
                heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID).OrderByDescending(x => x.STT).FirstOrDefault();
            }
            return(View(heThongSo));
        }
Exemple #10
0
        public JsonResult Show(int id)
        {
            HeThongSoViewModels hs = new HeThongSoViewModels();

            hs.ManHinhID = id;
            var       xp        = Mapper.Map <HeThongSoViewModels, HeThongSo>(hs);
            HeThongSo heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID && !x.Goi).OrderBy(x => x.STT).FirstOrDefault();

            if (heThongSo == null)
            {
                heThongSo = db.HeThongSos.Where(x => x.ManHinhID == xp.ManHinhID).OrderByDescending(x => x.STT).FirstOrDefault();
            }
            return(Json(heThongSo, JsonRequestBehavior.AllowGet));
        }
Exemple #11
0
        public async Task <IHttpActionResult> DeleteHeThongSo(int id)
        {
            HeThongSo heThongSo = await db.HeThongSos.FindAsync(id);

            if (heThongSo == null)
            {
                return(NotFound());
            }

            db.HeThongSos.Remove(heThongSo);
            await db.SaveChangesAsync();

            return(Ok(heThongSo));
        }
Exemple #12
0
        // GET: HeThongSoes/Edit/5
        public ActionResult Edit(int?id)
        {
            ViewBag.ManHinh = db.ManHinhs.ToList();
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HeThongSo heThongSo = db.HeThongSos.Find(id);

            if (heThongSo == null)
            {
                return(HttpNotFound());
            }
            return(View(heThongSo));
        }
Exemple #13
0
        public ActionResult Create([Bind(Include = "ID,STT,Goi,DateCreated,ManHinhID")] HeThongSo heThongSo)
        {
            ViewBag.ManHinh = db.ManHinhs.ToList();
            if (ModelState.IsValid)
            {
                int lastid = db.HeThongSos.Where(x => x.ManHinhID == heThongSo.ManHinhID).Count();
                lastid                 = lastid + 1;
                heThongSo.STT          = lastid;
                heThongSo.DateCreated  = DateTime.Now;
                heThongSo.Timers       = DateTime.Now;
                heThongSo.STTConfirmed = true;
                db.HeThongSos.Add(heThongSo);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(heThongSo));
        }