public IHttpActionResult Puttbl_ChuDe(long id, tbl_ChuDe tbl_ChuDe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_ChuDe.IDChuDe)
            {
                return(BadRequest());
            }

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

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!tbl_ChuDeExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        public IHttpActionResult Gettbl_ChuDe(long id)
        {
            tbl_ChuDe tbl_ChuDe = db.tbl_ChuDe.Find(id);

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

            return(Ok(tbl_ChuDe));
        }
Example #3
0
 public ActionResult Create(tbl_ChuDe model)
 {
     if (ModelState.IsValid)
     {
         var session = (UserLogin)Session[CommonConstants.USER_SESSION];
         model.sNguoiTao = session.UserName;
         new DanhMucBaiVietDAO().Create(model);
         return(RedirectToAction("Index"));
     }
     return(View());
 }
        public IHttpActionResult Posttbl_ChuDe(tbl_ChuDe tbl_ChuDe)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.tbl_ChuDe.Add(tbl_ChuDe);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = tbl_ChuDe.IDChuDe }, tbl_ChuDe));
        }
Example #5
0
        public long Create(tbl_ChuDe chude)
        {
            if (string.IsNullOrEmpty(chude.sTenChuDe))
            {
                chude.sTenChuDeMeta = StringHelper.ToUnsignString(chude.sTenChuDe);
            }
            chude.dNgayTao = DateTime.Now;
            db.tbl_ChuDe.Add(chude);
            db.SaveChanges();


            return(chude.IDChuDe);
        }
        public IHttpActionResult Deletetbl_ChuDe(long id)
        {
            tbl_ChuDe tbl_ChuDe = db.tbl_ChuDe.Find(id);

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

            db.tbl_ChuDe.Remove(tbl_ChuDe);
            db.SaveChanges();

            return(Ok(tbl_ChuDe));
        }
Example #7
0
        public ActionResult Edit(tbl_ChuDe model, FormCollection formcollection)
        {
            if (ModelState.IsValid)
            {
                long idchude = long.Parse(formcollection["hdnID"]);
                //var dao = new SanPhamDAO();
                var session = (UserLogin)Session[CommonConstants.USER_SESSION];
                model.sNguoiSua = session.UserName;
                model.IDChuDe   = idchude;

                //var result = dao.Edit(model);
                new DanhMucBaiVietDAO().Update(model);
                return(RedirectToAction("Index"));
            }
            return(View());
        }
Example #8
0
        public bool Update(tbl_ChuDe entity)
        {
            try
            {
                var chude = db.tbl_ChuDe.Find(entity.IDChuDe);
                chude.sTenChuDe = entity.sTenChuDe;
                if (string.IsNullOrEmpty(chude.sTenChuDeMeta))
                {
                    chude.sTenChuDeMeta = StringHelper.ToUnsignString(entity.sTenChuDe);
                }
                chude.sImage = entity.sImage;

                chude.bStatus  = entity.bStatus;
                chude.dNgaySua = DateTime.Now;

                db.SaveChanges();
                return(true);
            }
            catch (Exception ex)
            {
                return(false);
            }
        }