예제 #1
0
        public async Task <IActionResult> Modify([FromBody] AdDesignModels.Modify.Request request)
        {
            // Check session validation
            if (await CheckSessionValidationAndSignOutAsync() == false)
            {
                return(APIResponse(ErrorCode.InvalidSession));
            }

            // Check valid parameters
            if (request == null || request.IsValidParameters() == false)
            {
                return(APIResponse(ErrorCode.InvalidParameters));
            }

            DBKey        adDesignId   = request.AdDesignId;
            AdDesignData adDesignData = new AdDesignData();

            // Check validation
            if (await adDesignData.FromDBAsync(adDesignId) == false)
            {
                return(APIResponse(ErrorCode.InvalidParameters));
            }

            if (UserId != adDesignData.UserId)
            {
                return(APIResponse(ErrorCode.BadRequest));
            }

            AdResourceData adResourceData = new AdResourceData();

            if (await adResourceData.FromDBAsync(request.AdResourceId) == false)
            {
                return(APIResponse(ErrorCode.InvalidParameters));
            }

            // Update to db
            var updateQuery = new DBQuery_AdDesign_Update();
            var item        = updateQuery.IN.Item;

            request.Copy(item);
            item.UserId       = UserId;
            item.AdDesignType = adResourceData.AdDesignType;
            if (await DBThread.Instance.ReqQueryAsync(updateQuery) == false)
            {
                return(APIResponse(ErrorCode.DatabaseError));
            }

            // Response
            var response = new AdDesignModels.Modify.Response();

            if (await response.FromDBAsync(item.AdDesignId) == false)
            {
                return(APIResponse(ErrorCode.DatabaseError));
            }

            return(Success(response));
        }
예제 #2
0
 public bool FromDataTable(DataTable table)
 {
     try
     {
         foreach (DataRow row in table.Rows)
         {
             var item = new AdDesignData();
             item.FromDBTable(row);
             Items.Add(item);
         }
         return(true);
     }
     catch
     {
         return(false);
     }
 }
예제 #3
0
        public async Task <IActionResult> Delete([FromBody] AdDesignModels.Delete.Request request)
        {
            // Check session validation
            if (await CheckSessionValidationAndSignOutAsync() == false)
            {
                return(APIResponse(ErrorCode.InvalidSession));
            }

            // Check valid parameters
            if (request == null || request.IsValidParameters() == false)
            {
                return(APIResponse(ErrorCode.InvalidParameters));
            }

            DBKey        adDesignId   = request.AdDesignId;
            AdDesignData adDesignData = new AdDesignData();

            // Check validation
            if (await adDesignData.FromDBAsync(adDesignId) == false)
            {
                return(APIResponse(ErrorCode.DatabaseError));
            }

            if (UserId != adDesignData.UserId)
            {
                return(APIResponse(ErrorCode.BadRequest));
            }

            // Delete from db
            var deleteQuery = new DBQuery_AdDesign_Delete();

            deleteQuery.IN.DBKey = request.AdDesignId;
            if (await DBThread.Instance.ReqQueryAsync(deleteQuery) == false)
            {
                return(APIResponse(ErrorCode.DatabaseError));
            }

            // Response
            return(Success());
        }