Beispiel #1
0
        public static bool put_CAT_Tags(AppEntities db, int ID, DTO_CAT_Tags item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_CAT_Tags.Find(ID);

            if (dbitem != null)
            {
                dbitem.TenTag     = item.TenTag;
                dbitem.GhiChu     = item.GhiChu;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_Tags", DateTime.Now, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_CAT_Tags", e);
                    result = false;
                }
            }
            return(result);
        }
Beispiel #2
0
        public IHttpActionResult Get(int id)
        {
            DTO_CAT_Tags tbl_CAT_Tags = BS_CAT_Tags.get_CAT_Tags(db, id);

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

            return(Ok(tbl_CAT_Tags));
        }
Beispiel #3
0
        public IHttpActionResult Post(DTO_CAT_Tags tbl_CAT_Tags)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            DTO_CAT_Tags result = BS_CAT_Tags.post_CAT_Tags(db, tbl_CAT_Tags, Username);


            if (result != null)
            {
                return(CreatedAtRoute("get_CAT_Tags", new { id = result.ID }, result));
            }
            return(Conflict());
        }
Beispiel #4
0
        public static DTO_CAT_Tags post_CAT_Tags(AppEntities db, DTO_CAT_Tags item, string Username)
        {
            tbl_CAT_Tags dbitem = new tbl_CAT_Tags();

            if (item != null)
            {
                dbitem.TenTag     = item.TenTag;
                dbitem.GhiChu     = item.GhiChu;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;

                dbitem.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

                dbitem.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;


                try
                {
                    db.tbl_CAT_Tags.Add(dbitem);
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_CAT_Tags", DateTime.Now, Username);


                    item.ID = dbitem.ID;

                    item.CreatedBy   = dbitem.CreatedBy;
                    item.CreatedDate = dbitem.CreatedDate;

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_CAT_Tags", e);
                    item = null;
                }
            }
            return(item);
        }
Beispiel #5
0
        public IHttpActionResult Put(int id, DTO_CAT_Tags tbl_CAT_Tags)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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

            bool result = BS_CAT_Tags.put_CAT_Tags(db, id, tbl_CAT_Tags, Username);

            if (result)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }