Пример #1
0
        public IHttpActionResult Get(int id)
        {
            DTO_CUS_DOC_Folder tbl_CUS_DOC_Folder = BS_CUS_DOC_Folder.get_CUS_DOC_Folder(db, PartnerID, id);

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

            return(Ok(tbl_CUS_DOC_Folder));
        }
Пример #2
0
        public IHttpActionResult Post(DTO_CUS_DOC_Folder tbl_CUS_DOC_Folder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            DTO_CUS_DOC_Folder result = BS_CUS_DOC_Folder.post_CUS_DOC_Folder(db, PartnerID, tbl_CUS_DOC_Folder, Username);


            if (result != null)
            {
                return(CreatedAtRoute("get_CUS_DOC_Folder", new { id = result.ID }, result));
            }
            return(Conflict());
        }
Пример #3
0
        public IHttpActionResult Put(int id, DTO_CUS_DOC_Folder tbl_CUS_DOC_Folder)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != tbl_CUS_DOC_Folder.ID || PartnerID != tbl_CUS_DOC_Folder.IDPartner)
            {
                return(BadRequest());
            }


            bool resul = BS_CUS_DOC_Folder.put_CUS_DOC_Folder(db, PartnerID, id, tbl_CUS_DOC_Folder, Username);

            if (resul)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }
Пример #4
0
        public static bool put_CUS_DOC_Folder(AppEntities db, int PartnerID, int ID, DTO_CUS_DOC_Folder item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_CUS_DOC_Folder.Find(ID);

            if (dbitem != null)
            {
                dbitem.IDParent   = item.IDParent;
                dbitem.Code       = item.Code;
                dbitem.Name       = item.Name;
                dbitem.Remark     = item.Remark;
                dbitem.Sort       = item.Sort;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;
                dbitem.IDLinhVuc  = item.IDLinhVuc;

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

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_DOC_Folder", dbitem.ModifiedDate, Username);


                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_CUS_DOC_Folder", e);
                    result = false;
                }
            }
            return(result);
        }
Пример #5
0
        public static DTO_CUS_DOC_Folder post_CUS_DOC_Folder(AppEntities db, int PartnerID, DTO_CUS_DOC_Folder item, string Username)
        {
            tbl_CUS_DOC_Folder dbitem = new tbl_CUS_DOC_Folder();

            if (item != null)
            {
                dbitem.IDParent   = item.IDParent;
                dbitem.Code       = item.Code;
                dbitem.Name       = item.Name;
                dbitem.Remark     = item.Remark;
                dbitem.Sort       = item.Sort;
                dbitem.IsDisabled = item.IsDisabled;
                dbitem.IsDeleted  = item.IsDeleted;
                dbitem.IDLinhVuc  = item.IDLinhVuc;

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

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

                dbitem.IDPartner = PartnerID;


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

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_DOC_Folder", dbitem.ModifiedDate, Username);



                    item.ID = dbitem.ID;

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

                    item.ModifiedBy   = dbitem.ModifiedBy;
                    item.ModifiedDate = dbitem.ModifiedDate;

                    item.IDPartner = dbitem.IDPartner;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("post_CUS_DOC_Folder", e);
                    item = null;
                }
            }
            return(item);
        }