Example #1
0
        public IHttpActionResult Get(int id)
        {
            DTO_SYS_Form tbl_SYS_Form = BS_SYS_Form.get_SYS_Form(db, id);

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

            return(Ok(tbl_SYS_Form));
        }
Example #2
0
        public static DTO_SYS_Form post_SYS_Form(AppEntities db, DTO_SYS_Form item, string Username)
        {
            tbl_SYS_Form dbitem = new tbl_SYS_Form();

            if (item != null)
            {
                dbitem.IDFormGroup  = item.IDFormGroup;
                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.Type         = item.Type;
                dbitem.Icon         = item.Icon;
                dbitem.BadgeColor   = item.BadgeColor;
                dbitem.IsHiddenMenu = item.IsHiddenMenu;

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

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


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

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Form", dbitem.ModifiedDate, 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_SYS_Form", e);
                    item = null;
                }
            }
            return(item);
        }
Example #3
0
        public IHttpActionResult Post(DTO_SYS_Form tbl_SYS_Form)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            DTO_SYS_Form result = BS_SYS_Form.post_SYS_Form(db, tbl_SYS_Form, Username);


            if (result != null)
            {
                return(CreatedAtRoute("get_SYS_Form", new { id = result.ID }, result));
            }
            return(Conflict());
        }
Example #4
0
        public static bool put_SYS_Form(AppEntities db, int ID, DTO_SYS_Form item, string Username)
        {
            bool result = false;
            var  dbitem = db.tbl_SYS_Form.Find(ID);

            if (dbitem != null)
            {
                dbitem.IDFormGroup  = item.IDFormGroup;
                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.Type         = item.Type;
                dbitem.Icon         = item.Icon;
                dbitem.BadgeColor   = item.BadgeColor;
                dbitem.IsHiddenMenu = item.IsHiddenMenu;

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

                try
                {
                    db.SaveChanges();

                    BS_CUS_Version.update_CUS_Version(db, null, "DTO_SYS_Form", dbitem.ModifiedDate, Username);

                    result = true;
                }
                catch (DbEntityValidationException e)
                {
                    errorLog.logMessage("put_SYS_Form", e);
                    result = false;
                }
            }
            return(result);
        }
Example #5
0
        public IHttpActionResult Put(int id, DTO_SYS_Form tbl_SYS_Form)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

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


            bool resul = BS_SYS_Form.put_SYS_Form(db, id, tbl_SYS_Form, Username);

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