예제 #1
0
        public async Task <bool> AddPermissionObject(Permission_Object newObject)
        {
            var lastID = await base.DbConnection.QueryFirstAsync <string>("SELECT MAX(PermissionObj_ID) FROM dbo.Permission_Object WHERE PermissionObj_Type = @id",
                                                                          new
            {
                @id = newObject.PermissionObj_Type
            });

            if (await base.DbConnection.GetAsync <Permission_Object>(newObject.PermissionObj_Name) == null)
            {
                newObject.PermissionObj_Name = newObject.PermissionObj_Name;
                newObject.PermissionObj_Type = newObject.PermissionObj_Type;
                newObject.PermissionObj_ID   = "poid" + (Int32.Parse(lastID.Substring(4)) + 1).ToString();
                newObject.LastUpdateDate     = DateTime.Now;
                newObject.LastUpdateBy       = newObject.LastUpdateBy;
                newObject.IsActive           = true;
                await base.DbConnection.InsertAsync(newObject);

                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #2
0
        public bool UpdatePermissionObject(string user_ID, Permission_Object permission_Object)
        {
            var itemFromDb = base.DbConnection.Get <User>(permission_Object.PermissionObj_ID);

            if (itemFromDb != null)
            {
                itemFromDb.LastUpdateBy   = user_ID;
                itemFromDb.LastUpdateDate = DateTime.Now;
                return(base.DbConnection.Update(permission_Object));
            }
            return(false);
        }
예제 #3
0
        public async Task <IActionResult> AddPermissionObj(Permission_Object newObj, string user_ID)
        {
            //if(user_ID.Equals(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            //return Unauthorized();
            newObj.LastUpdateBy = user_ID;
            var isAdded = await _repo.AddPermissionObject(newObj);

            if (isAdded)
            {
                return(Ok());
            }
            else
            {
                return(BadRequest());
            }
        }
예제 #4
0
        public IActionResult UpdatePermissionObj(string id, string user_ID,
                                                 Permission_Object permission_Object)
        {
            if (!user_ID.Equals(User.FindFirst(ClaimTypes.NameIdentifier).Value))
            {
                return(Unauthorized());
            }
            permission_Object.LastUpdateBy   = user_ID;
            permission_Object.LastUpdateDate = DateTime.Now;
            var isUpdated = _repo.UpdatePermissionObject(id, permission_Object);

            if (isUpdated)
            {
                return(NoContent());
            }
            else
            {
                throw new Exception($"Updating Permission Object: {id} failed");
            }
        }