Example #1
0
        public static bool put_CUS_SYS_Role(AppEntities db, int PartnerID, int ID, DTO_CUS_SYS_Role item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_CUS_SYS_Role.Find(ID);

            if (dbitem != null)
            {
                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.ModifiedBy   = Username;
                dbitem.ModifiedDate = DateTime.Now;

                try
                {
                    db.SaveChanges();

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


                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_CUS_SYS_Role", e);
                    result = false;
                }
            }
            return(result);
        }
Example #2
0
        public IHttpActionResult Get(int id)
        {
            DTO_CUS_SYS_Role tbl_CUS_SYS_Role = BS_CUS_SYS_Role.get_CUS_SYS_Role(db, PartnerID, id);

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

            return(Ok(tbl_CUS_SYS_Role));
        }
Example #3
0
        public IHttpActionResult Post(DTO_CUS_SYS_Role tbl_CUS_SYS_Role)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            DTO_CUS_SYS_Role result = BS_CUS_SYS_Role.post_CUS_SYS_Role(db, PartnerID, tbl_CUS_SYS_Role, Username);


            if (result != null)
            {
                return(CreatedAtRoute("get_CUS_SYS_Role", new { id = result.ID }, result));
            }
            return(Conflict());
        }
Example #4
0
        public IHttpActionResult Put(int id, DTO_CUS_SYS_Role tbl_CUS_SYS_Role)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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


            bool resul = BS_CUS_SYS_Role.put_CUS_SYS_Role(db, PartnerID, id, tbl_CUS_SYS_Role, Username);

            if (resul)
            {
                return(StatusCode(HttpStatusCode.NoContent));
            }
            else
            {
                return(NotFound());
            }
        }
Example #5
0
        public static DTO_CUS_SYS_Role post_CUS_SYS_Role(AppEntities db, int PartnerID, DTO_CUS_SYS_Role item, string Username)
        {
            tbl_CUS_SYS_Role dbitem = new tbl_CUS_SYS_Role();

            if (item != null)
            {
                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.CreatedBy   = Username;
                dbitem.CreatedDate = DateTime.Now;

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

                dbitem.IDPartner = PartnerID;


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

                    BS_CUS_Version.update_CUS_Version(db, dbitem.IDPartner, "DTO_CUS_SYS_Role", 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_SYS_Role", e);
                    item = null;
                }
            }
            return(item);
        }